[flang-commits] [flang] c25bd6e - [flang][runtime] Teach ApplyType to handle TypeCategory::Unsigned (#123058)

via flang-commits flang-commits at lists.llvm.org
Thu Jan 16 03:08:54 PST 2025


Author: macurtis-amd
Date: 2025-01-16T05:08:49-06:00
New Revision: c25bd6e35134f591ee7dfeb4494df02987106f7e

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

LOG: [flang][runtime] Teach ApplyType to handle TypeCategory::Unsigned (#123058)

Added: 
    

Modified: 
    flang/runtime/tools.h
    flang/unittests/Runtime/Support.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/tools.h b/flang/runtime/tools.h
index 3fe3283415ba9f..facbd231610570 100644
--- a/flang/runtime/tools.h
+++ b/flang/runtime/tools.h
@@ -206,6 +206,23 @@ inline RT_API_ATTRS RESULT ApplyType(
     default:
       terminator.Crash("not yet implemented: INTEGER(KIND=%d)", kind);
     }
+  case TypeCategory::Unsigned:
+    switch (kind) {
+    case 1:
+      return FUNC<TypeCategory::Unsigned, 1>{}(std::forward<A>(x)...);
+    case 2:
+      return FUNC<TypeCategory::Unsigned, 2>{}(std::forward<A>(x)...);
+    case 4:
+      return FUNC<TypeCategory::Unsigned, 4>{}(std::forward<A>(x)...);
+    case 8:
+      return FUNC<TypeCategory::Unsigned, 8>{}(std::forward<A>(x)...);
+#if defined __SIZEOF_INT128__ && !AVOID_NATIVE_UINT128_T
+    case 16:
+      return FUNC<TypeCategory::Unsigned, 16>{}(std::forward<A>(x)...);
+#endif
+    default:
+      terminator.Crash("not yet implemented: UNSIGNED(KIND=%d)", kind);
+    }
   case TypeCategory::Real:
     switch (kind) {
 #if 0 // TODO: REAL(2 & 3)

diff  --git a/flang/unittests/Runtime/Support.cpp b/flang/unittests/Runtime/Support.cpp
index 9d1a417fdbf426..8c8de73b5b9798 100644
--- a/flang/unittests/Runtime/Support.cpp
+++ b/flang/unittests/Runtime/Support.cpp
@@ -67,3 +67,14 @@ TEST(IsAssumedSize, Basic) {
       std::vector<int>{}, std::vector<std::int32_t>{0})};
   EXPECT_FALSE(RTNAME(IsAssumedSize)(*scalar));
 }
+
+TEST(DescriptorBytesFor, Basic) {
+  for (size_t i = 0; i < Fortran::common::TypeCategory_enumSize; ++i) {
+    auto tc{static_cast<TypeCategory>(i)};
+    if (tc == TypeCategory::Derived)
+      continue;
+
+    auto b{Descriptor::BytesFor(tc, 4)};
+    EXPECT_GT(b, 0U);
+  }
+}


        


More information about the flang-commits mailing list