From 6f4f1023fafec4a470d8b7e8ea884c1953fe5291 Mon Sep 17 00:00:00 2001 From: Simi Pallipurath Date: Thu, 13 Jul 2023 14:32:05 +0100 Subject: [PATCH] [compiler-rt] [Arm] Make the tests for the runtime functions __aeabi_c{d,f} work on Big-Endian. We are trying to build the compiler-rt as big-endian. And found that the tests compiler-rt/test/builtins/Unit/arm/aeabi_cdcmpeq_test.c and compiler-rt/test/builtins/Unit/arm/aeabi_cfcmpeq_test.c do not work on big endian at the moment. This patch makes these tests work on big endian as well. Reviewed By: peter.smith, simon_tatham Differential Revision: https://reviews.llvm.org/D155208 --- compiler-rt/lib/builtins/arm/aeabi_cdcmp.S | 4 --- compiler-rt/lib/builtins/arm/aeabi_cfcmp.S | 4 --- compiler-rt/test/builtins/Unit/arm/call_apsr.h | 35 ++++++++++++++++++-------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/compiler-rt/lib/builtins/arm/aeabi_cdcmp.S b/compiler-rt/lib/builtins/arm/aeabi_cdcmp.S index bd039a0..c7abdb0 100644 --- a/compiler-rt/lib/builtins/arm/aeabi_cdcmp.S +++ b/compiler-rt/lib/builtins/arm/aeabi_cdcmp.S @@ -8,10 +8,6 @@ #include "../assembly.h" -#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ -#error big endian support not implemented -#endif - #define APSR_Z (1 << 30) #define APSR_C (1 << 29) diff --git a/compiler-rt/lib/builtins/arm/aeabi_cfcmp.S b/compiler-rt/lib/builtins/arm/aeabi_cfcmp.S index a26cb2a..81c4766 100644 --- a/compiler-rt/lib/builtins/arm/aeabi_cfcmp.S +++ b/compiler-rt/lib/builtins/arm/aeabi_cfcmp.S @@ -8,10 +8,6 @@ #include "../assembly.h" -#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ -#error big endian support not implemented -#endif - #define APSR_Z (1 << 30) #define APSR_C (1 << 29) diff --git a/compiler-rt/test/builtins/Unit/arm/call_apsr.h b/compiler-rt/test/builtins/Unit/arm/call_apsr.h index 87a7a74..09de115 100644 --- a/compiler-rt/test/builtins/Unit/arm/call_apsr.h +++ b/compiler-rt/test/builtins/Unit/arm/call_apsr.h @@ -1,21 +1,34 @@ #ifndef CALL_APSR_H #define CALL_APSR_H -#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ -#error big endian support not implemented -#endif +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ union cpsr { - struct { - uint32_t filler: 28; - uint32_t v: 1; - uint32_t c: 1; - uint32_t z: 1; - uint32_t n: 1; - } flags; - uint32_t value; + struct { + uint32_t filler : 28; + uint32_t v : 1; + uint32_t c : 1; + uint32_t z : 1; + uint32_t n : 1; + } flags; + uint32_t value; }; +#else + +union cpsr { + struct { + uint32_t n : 1; + uint32_t z : 1; + uint32_t c : 1; + uint32_t v : 1; + uint32_t filler : 28; + } flags; + uint32_t value; +}; + +#endif + __attribute__((noinline, pcs("aapcs"))) static uint32_t call_apsr_f(float a, float b, __attribute__((pcs("aapcs"))) void (*fn)(float, float)) { uint32_t result; -- 2.7.4