[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / floattisf_test.c
blobbf667d757440fa819a3280acb86b5f674e8143f1
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_floattisf
3 // REQUIRES: int128
4 //===-- floattisf_test.c - Test __floattisf -------------------------------===//
5 //
6 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
7 // See https://llvm.org/LICENSE.txt for license information.
8 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 //
10 //===----------------------------------------------------------------------===//
12 // This file tests __floattisf for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
16 #include "int_lib.h"
17 #include <float.h>
18 #include <stdio.h>
20 #ifdef CRT_HAS_128BIT
22 // Returns: convert a to a float, rounding toward even.
24 // Assumption: float is a IEEE 32 bit floating point type
25 // ti_int is a 64 bit integral type
27 // seee eeee emmm mmmm mmmm mmmm mmmm mmmm
29 COMPILER_RT_ABI float __floattisf(ti_int a);
31 int test__floattisf(ti_int a, float expected)
33 float x = __floattisf(a);
34 if (x != expected)
36 twords at;
37 at.all = a;
38 printf("error in __floattisf(0x%.16llX%.16llX) = %a, expected %a\n",
39 at.s.high, at.s.low, x, expected);
41 return x != expected;
44 char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
45 char assumption_2[sizeof(ti_int)*CHAR_BIT == 128] = {0};
46 char assumption_3[sizeof(float)*CHAR_BIT == 32] = {0};
48 #endif
50 int main()
52 #ifdef CRT_HAS_128BIT
53 if (test__floattisf(0, 0.0F))
54 return 1;
56 if (test__floattisf(1, 1.0F))
57 return 1;
58 if (test__floattisf(2, 2.0F))
59 return 1;
60 if (test__floattisf(-1, -1.0F))
61 return 1;
62 if (test__floattisf(-2, -2.0F))
63 return 1;
65 if (test__floattisf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62F))
66 return 1;
67 if (test__floattisf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62F))
68 return 1;
70 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000008000000000LL),
71 -0x1.FFFFFEp+62F))
72 return 1;
73 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000010000000000LL),
74 -0x1.FFFFFCp+62F))
75 return 1;
77 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000000LL),
78 -0x1.000000p+63F))
79 return 1;
80 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL),
81 -0x1.000000p+63F))
82 return 1;
84 if (test__floattisf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50F))
85 return 1;
87 if (test__floattisf(0x0007FB72EA000000LL, 0x1.FEDCBAp+50F))
88 return 1;
89 if (test__floattisf(0x0007FB72EB000000LL, 0x1.FEDCBAp+50F))
90 return 1;
91 if (test__floattisf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAp+50F))
92 return 1;
93 if (test__floattisf(0x0007FB72EC000000LL, 0x1.FEDCBCp+50F))
94 return 1;
95 if (test__floattisf(0x0007FB72E8000001LL, 0x1.FEDCBAp+50F))
96 return 1;
98 if (test__floattisf(0x0007FB72E6000000LL, 0x1.FEDCBAp+50F))
99 return 1;
100 if (test__floattisf(0x0007FB72E7000000LL, 0x1.FEDCBAp+50F))
101 return 1;
102 if (test__floattisf(0x0007FB72E7FFFFFFLL, 0x1.FEDCBAp+50F))
103 return 1;
104 if (test__floattisf(0x0007FB72E4000001LL, 0x1.FEDCBAp+50F))
105 return 1;
106 if (test__floattisf(0x0007FB72E4000000LL, 0x1.FEDCB8p+50F))
107 return 1;
109 if (test__floattisf(make_ti(0x0007FB72E8000000LL, 0), 0x1.FEDCBAp+114F))
110 return 1;
112 if (test__floattisf(make_ti(0x0007FB72EA000000LL, 0), 0x1.FEDCBAp+114F))
113 return 1;
114 if (test__floattisf(make_ti(0x0007FB72EB000000LL, 0), 0x1.FEDCBAp+114F))
115 return 1;
116 if (test__floattisf(make_ti(0x0007FB72EBFFFFFFLL, 0), 0x1.FEDCBAp+114F))
117 return 1;
118 if (test__floattisf(make_ti(0x0007FB72EC000000LL, 0), 0x1.FEDCBCp+114F))
119 return 1;
120 if (test__floattisf(make_ti(0x0007FB72E8000001LL, 0), 0x1.FEDCBAp+114F))
121 return 1;
123 if (test__floattisf(make_ti(0x0007FB72E6000000LL, 0), 0x1.FEDCBAp+114F))
124 return 1;
125 if (test__floattisf(make_ti(0x0007FB72E7000000LL, 0), 0x1.FEDCBAp+114F))
126 return 1;
127 if (test__floattisf(make_ti(0x0007FB72E7FFFFFFLL, 0), 0x1.FEDCBAp+114F))
128 return 1;
129 if (test__floattisf(make_ti(0x0007FB72E4000001LL, 0), 0x1.FEDCBAp+114F))
130 return 1;
131 if (test__floattisf(make_ti(0x0007FB72E4000000LL, 0), 0x1.FEDCB8p+114F))
132 return 1;
134 #else
135 printf("skipped\n");
136 #endif
137 return 0;