[compiler-rt] [compiler-rt] Make __aeabi_dcmp aware of endianness (PR #123204)

Victor Campos via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 06:05:35 PST 2025


https://github.com/vhscampos created https://github.com/llvm/llvm-project/pull/123204

This patch makes `__aeabi_dcmp` family of functions aware of endianness.

Before this patch, the functions' definitions assumed little endian, which made any program compiler for big endian incorrect.

>From b60c65d4d1aee576fa3bd681f6b4b8a767c07c12 Mon Sep 17 00:00:00 2001
From: Victor Campos <victor.campos at arm.com>
Date: Thu, 16 Jan 2025 11:27:09 +0000
Subject: [PATCH] [compiler-rt] Make __aeabi_dcmp aware of endianness

This patch makes `__aeabi_dcmp` family of functions aware of endianness.

Before this patch, the functions' definitions assumed little endian,
which made any program compiler for big endian incorrect.
---
 compiler-rt/lib/builtins/arm/aeabi_dcmp.S | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/builtins/arm/aeabi_dcmp.S b/compiler-rt/lib/builtins/arm/aeabi_dcmp.S
index 5f720670ddd7c1..4d2820741e9f0e 100644
--- a/compiler-rt/lib/builtins/arm/aeabi_dcmp.S
+++ b/compiler-rt/lib/builtins/arm/aeabi_dcmp.S
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "../assembly.h"
+#include "../int_endianness.h"
 
 // int __aeabi_dcmp{eq,lt,le,ge,gt}(double a, double b) {
 //   int result = __{eq,lt,le,ge,gt}df2(a, b);
@@ -17,10 +18,17 @@
 //   }
 // }
 
+
 #if defined(COMPILER_RT_ARMHF_TARGET)
-#  define CONVERT_DCMP_ARGS_TO_DF2_ARGS                    \
+#  if _YUGA_BIG_ENDIAN
+#    define CONVERT_DCMP_ARGS_TO_DF2_ARGS                  \
+        vmov      d0, r1, r0                     SEPARATOR \
+        vmov      d1, r3, r2
+#  else
+#    define CONVERT_DCMP_ARGS_TO_DF2_ARGS                  \
         vmov      d0, r0, r1                     SEPARATOR \
         vmov      d1, r2, r3
+#  endif
 #else
 #  define CONVERT_DCMP_ARGS_TO_DF2_ARGS
 #endif



More information about the llvm-commits mailing list