[flang-commits] [flang] 9a6d49e - [flang] Add IndexType support in getTypeAsString

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Tue May 23 14:15:34 PDT 2023


Author: Valentin Clement
Date: 2023-05-23T14:15:28-07:00
New Revision: 9a6d49e2d0f92ddd6fe4c6588c59a2912dae1ced

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

LOG: [flang] Add IndexType support in getTypeAsString

Reviewed By: razvanlupusoru

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

Added: 
    

Modified: 
    flang/lib/Optimizer/Dialect/FIRType.cpp
    flang/unittests/Optimizer/FIRTypesTest.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp
index 50268287bee61..f36436ec5bc34 100644
--- a/flang/lib/Optimizer/Dialect/FIRType.cpp
+++ b/flang/lib/Optimizer/Dialect/FIRType.cpp
@@ -489,7 +489,9 @@ std::string getTypeAsString(mlir::Type ty, const fir::KindMapping &kindMap,
   ty = fir::unwrapRefType(ty);
   while (ty) {
     if (fir::isa_trivial(ty)) {
-      if (ty.isIntOrIndex()) {
+      if (mlir::isa<mlir::IndexType>(ty)) {
+        name << "idx";
+      } else if (ty.isIntOrIndex()) {
         name << 'i' << ty.getIntOrFloatBitWidth();
       } else if (ty.isa<mlir::FloatType>()) {
         name << 'f' << ty.getIntOrFloatBitWidth();

diff  --git a/flang/unittests/Optimizer/FIRTypesTest.cpp b/flang/unittests/Optimizer/FIRTypesTest.cpp
index 052d479b86521..2e08d8a759b01 100644
--- a/flang/unittests/Optimizer/FIRTypesTest.cpp
+++ b/flang/unittests/Optimizer/FIRTypesTest.cpp
@@ -277,4 +277,6 @@ TEST_F(FIRTypesTest, getTypeAsString) {
   mlir::Type ty = mlir::IntegerType::get(&context, 64);
   mlir::Type arrTy = fir::SequenceType::get({10, 20}, ty);
   EXPECT_EQ("10x20xi64", fir::getTypeAsString(arrTy, *kindMap));
+  EXPECT_EQ(
+      "idx", fir::getTypeAsString(mlir::IndexType::get(&context), *kindMap));
 }


        


More information about the flang-commits mailing list