Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

macurtis-amd
Copy link
Contributor

No description provided.

@llvmbot llvmbot added flang:runtime flang Flang issues not falling into any other category labels Jan 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 15, 2025

@llvm/pr-subscribers-flang-runtime

Author: None (macurtis-amd)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/123058.diff

2 Files Affected:

  • (modified) flang/runtime/tools.h (+17)
  • (modified) flang/unittests/Runtime/Support.cpp (+11)
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);
+  }
+}

Copy link
Contributor

@mjklemm mjklemm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@macurtis-amd macurtis-amd merged commit c25bd6e into llvm:main Jan 16, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:runtime flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants