[PATCH] D113769: [fir] !fir.tdesc type conversion
Valentin Clement via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 12 06:48:44 PST 2021
clementval created this revision.
clementval added reviewers: jeanPerier, svedanayagam, sscalpone, kiranchandramohan, jdoerfert, schweitz, pmccormick, rovka, AlexisPerry, PeteSteinfeld, awarzynski.
Herald added a subscriber: mehdi_amini.
Herald added a project: Flang.
clementval requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Add !fir.tdesc type conversion.
!fir.tdesc is converted to a llvm.ptr<i8>.
This patch is part of the upstreaming effort from fir-dev branch.
Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>
Co-authored-by: Jean Perier <jperier at nvidia.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113769
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
@@ -293,3 +293,11 @@
func private @foo0(%arg0: !fir.field)
// CHECK-LABEL: foo0
// CHECK-SAME: i32
+
+// -----
+
+// Test `!fir.tdesc` conversion.
+
+func private @foo0(%arg0: !fir.tdesc<!fir.type<x>>)
+// CHECK-LABEL: foo0
+// CHECK-SAME: !llvm.ptr<i8>
Index: flang/lib/Optimizer/CodeGen/TypeConverter.h
===================================================================
--- flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -82,6 +82,9 @@
addConversion([&](fir::SequenceType sequence) {
return convertSequenceType(sequence);
});
+ addConversion([&](fir::TypeDescType tdesc) {
+ return convertTypeDescType(tdesc.getContext());
+ });
addConversion([&](fir::VectorType vecTy) {
return mlir::VectorType::get(llvm::ArrayRef<int64_t>(vecTy.getLen()),
convertType(vecTy.getEleTy()));
@@ -275,6 +278,14 @@
return mlir::LLVM::LLVMPointerType::get(baseTy);
}
+ // fir.tdesc<any> --> llvm<"i8*">
+ // TODO: For now use a void*, however pointer identity is not sufficient for
+ // the f18 object v. class distinction (F2003).
+ mlir::Type convertTypeDescType(mlir::MLIRContext *ctx) {
+ return mlir::LLVM::LLVMPointerType::get(
+ mlir::IntegerType::get(&getContext(), 8));
+ }
+
/// Convert llvm::Type::TypeID to mlir::Type
mlir::Type fromRealTypeID(llvm::Type::TypeID typeID, fir::KindTy kind) {
switch (typeID) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113769.386837.patch
Type: text/x-patch
Size: 1651 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211112/9cf3c445/attachment.bin>
More information about the llvm-commits
mailing list