[flang-commits] [flang] [flang] Support fir.boxchar in getTypeAsString (PR #70997)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Wed Nov 1 15:23:02 PDT 2023
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/70997
None
>From 15b2abc4904094a79f6dedd3f6d42ea3074d26a7 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Wed, 1 Nov 2023 15:21:20 -0700
Subject: [PATCH] [flang] Support fir.boxchar in getTypeAsString
---
flang/lib/Optimizer/Dialect/FIRType.cpp | 7 ++++++-
flang/unittests/Optimizer/FIRTypesTest.cpp | 2 ++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp
index 323b589cc7f2eb1..09c2a7875843f2f 100644
--- a/flang/lib/Optimizer/Dialect/FIRType.cpp
+++ b/flang/lib/Optimizer/Dialect/FIRType.cpp
@@ -545,7 +545,9 @@ std::string getTypeAsString(mlir::Type ty, const fir::KindMapping &kindMap,
break;
} else if (auto charTy = mlir::dyn_cast_or_null<fir::CharacterType>(ty)) {
name << 'c' << kindMap.getCharacterBitsize(charTy.getFKind());
- if (charTy.getLen() != fir::CharacterType::singleton())
+ if (charTy.getLen() == fir::CharacterType::unknownLen())
+ name << "x?";
+ else if (charTy.getLen() != fir::CharacterType::singleton())
name << "x" << charTy.getLen();
break;
} else if (auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(ty)) {
@@ -574,6 +576,9 @@ std::string getTypeAsString(mlir::Type ty, const fir::KindMapping &kindMap,
} else if (auto boxTy = mlir::dyn_cast_or_null<fir::BoxType>(ty)) {
name << "box_";
ty = boxTy.getEleTy();
+ } else if (auto boxcharTy = mlir::dyn_cast_or_null<fir::BoxCharType>(ty)) {
+ name << "boxchar_";
+ ty = boxcharTy.getEleTy();
} else if (auto recTy = mlir::dyn_cast_or_null<fir::RecordType>(ty)) {
name << "rec_" << recTy.getName();
break;
diff --git a/flang/unittests/Optimizer/FIRTypesTest.cpp b/flang/unittests/Optimizer/FIRTypesTest.cpp
index b66c1ff441badeb..82846fff5847651 100644
--- a/flang/unittests/Optimizer/FIRTypesTest.cpp
+++ b/flang/unittests/Optimizer/FIRTypesTest.cpp
@@ -313,4 +313,6 @@ TEST_F(FIRTypesTest, getTypeAsString) {
fir::getTypeAsString(
fir::LLVMPointerType::get(mlir::IntegerType::get(&context, 32)),
*kindMap));
+ EXPECT_EQ("boxchar_c8x?",
+ fir::getTypeAsString(fir::BoxCharType::get(&context, 1), *kindMap));
}
More information about the flang-commits
mailing list