[flang-commits] [flang] ee95b64 - [flang] Support fir.llvm_ptr in getTypeAsString
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Fri Aug 25 14:15:24 PDT 2023
Author: Valentin Clement
Date: 2023-08-25T14:15:18-07:00
New Revision: ee95b64adb7f94ec3ddfe71258ef28e1168001eb
URL: https://github.com/llvm/llvm-project/commit/ee95b64adb7f94ec3ddfe71258ef28e1168001eb
DIFF: https://github.com/llvm/llvm-project/commit/ee95b64adb7f94ec3ddfe71258ef28e1168001eb.diff
LOG: [flang] Support fir.llvm_ptr in getTypeAsString
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D158888
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 c1fc8494cb65d1..dd79aa27645452 100644
--- a/flang/lib/Optimizer/Dialect/FIRType.cpp
+++ b/flang/lib/Optimizer/Dialect/FIRType.cpp
@@ -531,6 +531,9 @@ std::string getTypeAsString(mlir::Type ty, const fir::KindMapping &kindMap,
} else if (auto ptrTy = mlir::dyn_cast_or_null<fir::PointerType>(ty)) {
name << "ptr_";
ty = ptrTy.getEleTy();
+ } else if (auto ptrTy = mlir::dyn_cast_or_null<fir::LLVMPointerType>(ty)) {
+ name << "llvmptr_";
+ ty = ptrTy.getEleTy();
} else if (auto heapTy = mlir::dyn_cast_or_null<fir::HeapType>(ty)) {
name << "heap_";
ty = heapTy.getEleTy();
diff --git a/flang/unittests/Optimizer/FIRTypesTest.cpp b/flang/unittests/Optimizer/FIRTypesTest.cpp
index 6a9842c8ed2d07..2bde6f556bdc82 100644
--- a/flang/unittests/Optimizer/FIRTypesTest.cpp
+++ b/flang/unittests/Optimizer/FIRTypesTest.cpp
@@ -309,4 +309,8 @@ TEST_F(FIRTypesTest, getTypeAsString) {
fir::SequenceType::getUnknownExtent()},
ty);
EXPECT_EQ("?x?xi64", fir::getTypeAsString(dynArrTy, *kindMap));
+ EXPECT_EQ("llvmptr_i32",
+ fir::getTypeAsString(
+ fir::LLVMPointerType::get(mlir::IntegerType::get(&context, 32)),
+ *kindMap));
}
More information about the flang-commits
mailing list