[PATCH] D113571: [flang][codegen] Add type conversion for `fir.boxchar`
Andrzej Warzynski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 11 02:30:19 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb2018261e80: [flang][codegen] Add type conversion for `fir.boxchar` (authored by awarzynski).
Changed prior to commit:
https://reviews.llvm.org/D113571?vs=386174&id=386462#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113571/new/
https://reviews.llvm.org/D113571
Files:
flang/lib/Optimizer/CodeGen/Target.cpp
flang/lib/Optimizer/CodeGen/Target.h
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
@@ -203,3 +203,15 @@
func private @foo16(%arg0: !fir.vector<2:!fir.real<16>>)
// CHECK-LABEL: foo16
// CHECK-SAME: vector<2xf128>
+
+// -----
+
+// Test `!fir.boxchar<n>` conversion
+
+func private @foo0(%arg0: !fir.boxchar<1>)
+// CHECK-LABEL: foo0
+// CHECK-SAME: !llvm.struct<(ptr<i8>, i64)>
+
+func private @foo1(%arg0: !fir.boxchar<2>)
+// CHECK-LABEL: foo1
+// CHECK-SAME: !llvm.struct<(ptr<i16>, i64)>
Index: flang/lib/Optimizer/CodeGen/TypeConverter.h
===================================================================
--- flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -50,6 +50,10 @@
// Each conversion should return a value of type mlir::Type.
addConversion([&](BoxType box) { return convertBoxType(box); });
+ addConversion([&](BoxCharType boxchar) {
+ LLVM_DEBUG(llvm::dbgs() << "type convert: " << boxchar << '\n');
+ return convertType(specifics->boxcharMemoryType(boxchar.getEleTy()));
+ });
addConversion(
[&](fir::CharacterType charTy) { return convertCharType(charTy); });
addConversion([&](fir::LogicalType boolTy) {
Index: flang/lib/Optimizer/CodeGen/Target.h
===================================================================
--- flang/lib/Optimizer/CodeGen/Target.h
+++ flang/lib/Optimizer/CodeGen/Target.h
@@ -77,6 +77,9 @@
/// value may need to be converted to a hidden reference argument.
virtual Marshalling complexReturnType(mlir::Type eleTy) const = 0;
+ /// Type presentation of a `boxchar<n>` type value in memory.
+ virtual mlir::Type boxcharMemoryType(mlir::Type eleTy) const = 0;
+
/// Type representation of a `boxchar<n>` type argument when passed by value.
/// An argument value may need to be passed as a (safe) reference argument.
///
Index: flang/lib/Optimizer/CodeGen/Target.cpp
===================================================================
--- flang/lib/Optimizer/CodeGen/Target.cpp
+++ flang/lib/Optimizer/CodeGen/Target.cpp
@@ -42,6 +42,14 @@
return mlir::TupleType::get(eleTy.getContext(), range);
}
+ mlir::Type boxcharMemoryType(mlir::Type eleTy) const override {
+ auto idxTy = mlir::IntegerType::get(eleTy.getContext(), S::defaultWidth);
+ auto ptrTy = fir::ReferenceType::get(eleTy);
+ // { t*, index }
+ mlir::TypeRange range = {ptrTy, idxTy};
+ return mlir::TupleType::get(eleTy.getContext(), range);
+ }
+
Marshalling boxcharArgumentType(mlir::Type eleTy, bool sret) const override {
CodeGenSpecifics::Marshalling marshal;
auto idxTy = mlir::IntegerType::get(eleTy.getContext(), S::defaultWidth);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113571.386462.patch
Type: text/x-patch
Size: 2797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211111/c5e0809f/attachment.bin>
More information about the llvm-commits
mailing list