[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / fixtfdi_test.c
blob32f63236e7bb1b277d857d2c79b2ec719804a1ba
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_fixtfdi
3 //===--------------- fixtfdi_test.c - Test __fixtfdi ----------------------===//
4 //
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //
9 //===----------------------------------------------------------------------===//
11 // This file tests __fixtfdi for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include "int_lib.h"
16 #include <stdio.h>
18 #if __LDBL_MANT_DIG__ == 113
20 #include "fp_test.h"
22 di_int __fixtfdi(long double a);
24 int test__fixtfdi(long double a, di_int expected)
26 di_int x = __fixtfdi(a);
27 int ret = (x != expected);
29 if (ret)
31 printf("error in test__fixtfdi(%.20Lf) = %llX, "
32 "expected %llX\n", a, x, expected);
34 return ret;
37 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
39 #endif
41 int main()
43 #if __LDBL_MANT_DIG__ == 113
44 if (test__fixtfdi(makeInf128(), 0x7fffffffffffffffLL))
45 return 1;
46 if (test__fixtfdi(0, 0x0))
47 return 1;
48 if (test__fixtfdi(0x1.23456789abcdefp+5L, 0x24LL))
49 return 1;
50 if (test__fixtfdi(0x1.23456789abcdefp-3L, 0x0LL))
51 return 1;
52 if (test__fixtfdi(0x1.23456789abcdef12345678p+20L, 0x123456LL))
53 return 1;
54 if (test__fixtfdi(0x1.23456789abcdef12345678p+40L, 0x123456789abLL))
55 return 1;
56 if (test__fixtfdi(0x1.23456789abcdef12345678p+60L, 0x123456789abcdef1LL))
57 return 1;
58 if (test__fixtfdi(0x1.23456789abcdefp+256L, 0x7fffffffffffffffLL))
59 return 1;
60 if (test__fixtfdi(-0x1.23456789abcdefp+20L, 0xffffffffffedcbaaLL))
61 return 1;
62 if (test__fixtfdi(-0x1.23456789abcdefp+40L, 0xfffffedcba987655LL))
63 return 1;
64 if (test__fixtfdi(-0x1.23456789abcdefp+256L, 0x8000000000000000LL))
65 return 1;
67 #else
68 printf("skipped\n");
70 #endif
71 return 0;