1 //===-- aeabi_cfcmpeq.c - Test __aeabi_cfcmpeq ----------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file tests __aeabi_cfcmpeq for the compiler_rt library.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include <stdint.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <math.h>
18
19 #if __arm__
20 #include "call_apsr.h"
21
22 extern __attribute__((pcs("aapcs"))) void __aeabi_cfcmpeq(float a, float b);
23
test__aeabi_cfcmpeq(float a,float b,int expected)24 int test__aeabi_cfcmpeq(float a, float b, int expected)
25 {
26 uint32_t cpsr_value = call_apsr_f(a, b, __aeabi_cfcmpeq);
27 union cpsr cpsr = { .value = cpsr_value };
28 if (expected != cpsr.flags.z) {
29 printf("error in __aeabi_cfcmpeq(%f, %f) => Z = %d, expected %d\n",
30 a, b, cpsr.flags.z, expected);
31 return 1;
32 }
33 return 0;
34 }
35 #endif
36
main()37 int main()
38 {
39 #if __arm__
40 if (test__aeabi_cfcmpeq(1.0, 1.0, 1))
41 return 1;
42 if (test__aeabi_cfcmpeq(1234.567, 765.4321, 0))
43 return 1;
44 if (test__aeabi_cfcmpeq(-123.0, -678.0, 0))
45 return 1;
46 if (test__aeabi_cfcmpeq(0.0, -0.0, 1))
47 return 1;
48 if (test__aeabi_cfcmpeq(1.0, NAN, 0))
49 return 1;
50 if (test__aeabi_cfcmpeq(NAN, 1.0, 0))
51 return 1;
52 if (test__aeabi_cfcmpeq(NAN, NAN, 0))
53 return 1;
54 if (test__aeabi_cfcmpeq(INFINITY, 1.0, 0))
55 return 1;
56 if (test__aeabi_cfcmpeq(0.0, INFINITY, 0))
57 return 1;
58 if (test__aeabi_cfcmpeq(-INFINITY, 0.0, 0))
59 return 1;
60 if (test__aeabi_cfcmpeq(0.0, -INFINITY, 0))
61 return 1;
62 if (test__aeabi_cfcmpeq(INFINITY, INFINITY, 1))
63 return 1;
64 if (test__aeabi_cfcmpeq(-INFINITY, -INFINITY, 1))
65 return 1;
66 #else
67 printf("skipped\n");
68 #endif
69 return 0;
70 }
71