Skip to content

[compiler-rt] Add initial ARM64EC builtins support #139279

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cjacek
Copy link
Contributor

@cjacek cjacek commented May 9, 2025

Use the aarch64 variants of assembly functions.

Based on a patch by Billy Laws.

Use the aarch64 variants of assembly functions.

Based on a patch by Billy Laws.
Copy link

github-actions bot commented May 9, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff HEAD~1 HEAD --extensions h,inc,c -- compiler-rt/lib/builtins/clear_cache.c compiler-rt/lib/builtins/cpu_model/aarch64.c compiler-rt/lib/builtins/cpu_model/aarch64.h compiler-rt/lib/builtins/fp_compare_impl.inc compiler-rt/lib/builtins/fp_lib.h compiler-rt/lib/builtins/udivmodti4.c compiler-rt/test/builtins/Unit/enable_execute_stack_test.c compiler-rt/test/builtins/Unit/fixunstfdi_test.c compiler-rt/test/builtins/Unit/multc3_test.c
View the diff from clang-format here.
diff --git a/compiler-rt/test/builtins/Unit/fixunstfdi_test.c b/compiler-rt/test/builtins/Unit/fixunstfdi_test.c
index 982f3a462..0a66602fa 100644
--- a/compiler-rt/test/builtins/Unit/fixunstfdi_test.c
+++ b/compiler-rt/test/builtins/Unit/fixunstfdi_test.c
@@ -6,7 +6,7 @@
 
 #if _ARCH_PPC || __aarch64__ || __arm64ec__
 
-#include "int_lib.h"
+#  include "int_lib.h"
 
 // Returns: convert a to a unsigned long long, rounding toward zero.
 //          Negative values all become zero.
@@ -36,77 +36,77 @@ char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0};
 int main()
 {
 #if _ARCH_PPC || __aarch64__ || __arm64ec__
-    if (test__fixunstfdi(0.0, 0))
-        return 1;
-
-    if (test__fixunstfdi(0.5, 0))
-        return 1;
-    if (test__fixunstfdi(0.99, 0))
-        return 1;
-    if (test__fixunstfdi(1.0, 1))
-        return 1;
-    if (test__fixunstfdi(1.5, 1))
-        return 1;
-    if (test__fixunstfdi(1.99, 1))
-        return 1;
-    if (test__fixunstfdi(2.0, 2))
-        return 1;
-    if (test__fixunstfdi(2.01, 2))
-        return 1;
-    if (test__fixunstfdi(-0.5, 0))
-        return 1;
-    if (test__fixunstfdi(-0.99, 0))
-        return 1;
-    if (test__fixunstfdi(-1.0, 0))
-        return 1;
-    if (test__fixunstfdi(-1.5, 0))
-        return 1;
-    if (test__fixunstfdi(-1.99, 0))
-        return 1;
-    if (test__fixunstfdi(-2.0, 0))
-        return 1;
-    if (test__fixunstfdi(-2.01, 0))
-        return 1;
-
-    if (test__fixunstfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
-        return 1;
-    if (test__fixunstfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
-        return 1;
-
-    if (test__fixunstfdi(-0x1.FFFFFEp+62, 0))
-        return 1;
-    if (test__fixunstfdi(-0x1.FFFFFCp+62, 0))
-        return 1;
-
-    if (test__fixunstfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
-        return 1;
-    if (test__fixunstfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
-        return 1;
-
-    if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFp+62, 0))
-        return 1;
-    if (test__fixunstfdi(-0x1.FFFFFFFFFFFFEp+62, 0))
-        return 1;
-
-    if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFFEp+63L, 0xFFFFFFFFFFFFFFFFLL))
-        return 1;
-    if (test__fixunstfdi(0x1.0000000000000002p+63L, 0x8000000000000001LL))
-        return 1;
-    if (test__fixunstfdi(0x1.0000000000000000p+63L, 0x8000000000000000LL))
-        return 1;
-    if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFFCp+62L, 0x7FFFFFFFFFFFFFFFLL))
-        return 1;
-    if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFF8p+62L, 0x7FFFFFFFFFFFFFFELL))
-        return 1;
-    if (test__fixunstfdi(0x1.p+64L, 0xFFFFFFFFFFFFFFFFLL))
-        return 1;
-
-    if (test__fixunstfdi(-0x1.0000000000000000p+63L, 0))
-        return 1;
-    if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFFFCp+62L, 0))
-        return 1;
-    if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFFF8p+62L, 0))
-        return 1;
+  if (test__fixunstfdi(0.0, 0))
+    return 1;
+
+  if (test__fixunstfdi(0.5, 0))
+    return 1;
+  if (test__fixunstfdi(0.99, 0))
+    return 1;
+  if (test__fixunstfdi(1.0, 1))
+    return 1;
+  if (test__fixunstfdi(1.5, 1))
+    return 1;
+  if (test__fixunstfdi(1.99, 1))
+    return 1;
+  if (test__fixunstfdi(2.0, 2))
+    return 1;
+  if (test__fixunstfdi(2.01, 2))
+    return 1;
+  if (test__fixunstfdi(-0.5, 0))
+    return 1;
+  if (test__fixunstfdi(-0.99, 0))
+    return 1;
+  if (test__fixunstfdi(-1.0, 0))
+    return 1;
+  if (test__fixunstfdi(-1.5, 0))
+    return 1;
+  if (test__fixunstfdi(-1.99, 0))
+    return 1;
+  if (test__fixunstfdi(-2.0, 0))
+    return 1;
+  if (test__fixunstfdi(-2.01, 0))
+    return 1;
+
+  if (test__fixunstfdi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL))
+    return 1;
+  if (test__fixunstfdi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL))
+    return 1;
+
+  if (test__fixunstfdi(-0x1.FFFFFEp+62, 0))
+    return 1;
+  if (test__fixunstfdi(-0x1.FFFFFCp+62, 0))
+    return 1;
+
+  if (test__fixunstfdi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL))
+    return 1;
+  if (test__fixunstfdi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL))
+    return 1;
+
+  if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFp+62, 0))
+    return 1;
+  if (test__fixunstfdi(-0x1.FFFFFFFFFFFFEp+62, 0))
+    return 1;
+
+  if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFFEp+63L, 0xFFFFFFFFFFFFFFFFLL))
+    return 1;
+  if (test__fixunstfdi(0x1.0000000000000002p+63L, 0x8000000000000001LL))
+    return 1;
+  if (test__fixunstfdi(0x1.0000000000000000p+63L, 0x8000000000000000LL))
+    return 1;
+  if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFFCp+62L, 0x7FFFFFFFFFFFFFFFLL))
+    return 1;
+  if (test__fixunstfdi(0x1.FFFFFFFFFFFFFFF8p+62L, 0x7FFFFFFFFFFFFFFELL))
+    return 1;
+  if (test__fixunstfdi(0x1.p+64L, 0xFFFFFFFFFFFFFFFFLL))
+    return 1;
+
+  if (test__fixunstfdi(-0x1.0000000000000000p+63L, 0))
+    return 1;
+  if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFFFCp+62L, 0))
+    return 1;
+  if (test__fixunstfdi(-0x1.FFFFFFFFFFFFFFF8p+62L, 0))
+    return 1;
 
 #else
     printf("skipped\n");
diff --git a/compiler-rt/test/builtins/Unit/multc3_test.c b/compiler-rt/test/builtins/Unit/multc3_test.c
index e9c99a72b..44707c75d 100644
--- a/compiler-rt/test/builtins/Unit/multc3_test.c
+++ b/compiler-rt/test/builtins/Unit/multc3_test.c
@@ -6,9 +6,9 @@
 
 #if _ARCH_PPC || __aarch64__ || __arm64ec__
 
-#include "int_lib.h"
-#include <math.h>
-#include <complex.h>
+#  include "int_lib.h"
+#  include <math.h>
+#  include <complex.h>
 
 // Returns: the product of a + ib and c + id
 
@@ -349,16 +349,14 @@ long double x[][2] =
 int main()
 {
 #if _ARCH_PPC || __aarch64__ || __arm64ec__
-    const unsigned N = sizeof(x) / sizeof(x[0]);
-    unsigned i, j;
-    for (i = 0; i < N; ++i)
-    {
-        for (j = 0; j < N; ++j)
-        {
-            if (test__multc3(x[i][0], x[i][1], x[j][0], x[j][1]))
-                return 1;
-        }
+  const unsigned N = sizeof(x) / sizeof(x[0]);
+  unsigned i, j;
+  for (i = 0; i < N; ++i) {
+    for (j = 0; j < N; ++j) {
+      if (test__multc3(x[i][0], x[i][1], x[j][0], x[j][1]))
+        return 1;
     }
+  }
 #else
     printf("skipped\n");
 #endif

@cjacek
Copy link
Contributor Author

cjacek commented May 9, 2025

The code formatting errors relate to existing formatting around my changes. Including those in the diff would be misleading, in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants