1 // REQUIRES: arm-target-arch || armv6m-target-arch
2 // RUN: %arm_call_apsr -o %t.aspr.o
3 // RUN: %clang_builtins %s %t.aspr.o %librt -o %t && %run %t
5 //===-- aeabi_cdcmple.c - Test __aeabi_cdcmple and __aeabi_cdrcmple -------===//
7 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8 // See https://llvm.org/LICENSE.txt for license information.
9 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11 //===----------------------------------------------------------------------===//
13 // This file tests __aeabi_cdcmple and __aeabi_cdrcmple for the compiler_rt
16 //===----------------------------------------------------------------------===//
23 #include "call_apsr.h"
27 extern __attribute__((pcs("aapcs"))) void __aeabi_cdcmple(double a
, double b
);
28 extern __attribute__((pcs("aapcs"))) void __aeabi_cdrcmple(double a
, double b
);
30 int test__aeabi_cdcmple(double a
, double b
, int expected
)
32 int32_t cpsr_value
= call_apsr_d(a
, b
, __aeabi_cdcmple
);
33 int32_t r_cpsr_value
= call_apsr_d(b
, a
, __aeabi_cdrcmple
);
35 if (cpsr_value
!= r_cpsr_value
) {
36 printf("error: __aeabi_cdcmple(%f, %f) != __aeabi_cdrcmple(%f, %f)\n", a
, b
, b
, a
);
40 int expected_z
, expected_c
;
44 } else if (expected
== 0) {
48 // a or b is NaN, or a > b
53 union cpsr cpsr
= { .value
= cpsr_value
};
54 if (expected_z
!= cpsr
.flags
.z
|| expected_c
!= cpsr
.flags
.c
) {
55 printf("error in __aeabi_cdcmple(%f, %f) => (Z = %d, C = %d), expected (Z = %d, C = %d)\n",
56 a
, b
, cpsr
.flags
.z
, cpsr
.flags
.c
, expected_z
, expected_c
);
60 cpsr
.value
= r_cpsr_value
;
61 if (expected_z
!= cpsr
.flags
.z
|| expected_c
!= cpsr
.flags
.c
) {
62 printf("error in __aeabi_cdrcmple(%f, %f) => (Z = %d, C = %d), expected (Z = %d, C = %d)\n",
63 a
, b
, cpsr
.flags
.z
, cpsr
.flags
.c
, expected_z
, expected_c
);
73 if (test__aeabi_cdcmple(1.0, 1.0, 0))
75 if (test__aeabi_cdcmple(1234.567, 765.4321, 1))
77 if (test__aeabi_cdcmple(765.4321, 1234.567, -1))
79 if (test__aeabi_cdcmple(-123.0, -678.0, 1))
81 if (test__aeabi_cdcmple(-678.0, -123.0, -1))
83 if (test__aeabi_cdcmple(0.0, -0.0, 0))
85 if (test__aeabi_cdcmple(1.0, NAN
, 1))
87 if (test__aeabi_cdcmple(NAN
, 1.0, 1))
89 if (test__aeabi_cdcmple(NAN
, NAN
, 1))