[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / fixtfti_test.c
blob5bafb68c7a9f7aec66b8f910e03376ab1b2bea34
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_fixtfti
3 //===--------------- fixtfti_test.c - Test __fixtfti ----------------------===//
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 __fixtfti 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 ti_int __fixtfti(long double a);
24 int test__fixtfti(long double a, ti_int expected)
26 ti_int x = __fixtfti(a);
27 int ret = (x != expected);
29 if (ret)
31 twords xt;
32 xt.all = x;
34 twords expectedt;
35 expectedt.all = expected;
37 printf("error in test__fixtfti(%.20Lf) = 0x%.16llX%.16llX, "
38 "expected 0x%.16llX%.16llX\n",
39 a, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low);
41 return ret;
44 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
46 #endif
48 int main()
50 #if __LDBL_MANT_DIG__ == 113
51 if (test__fixtfti(makeInf128(), make_ti(0x7fffffffffffffffLL,
52 0xffffffffffffffffLL)))
53 return 1;
54 if (test__fixtfti(0, make_ti(0x0LL, 0x0LL)))
55 return 1;
56 if (test__fixtfti(0x1.23456789abcdefp+5L, make_ti(0x0LL, 0x24LL)))
57 return 1;
58 if (test__fixtfti(0x1.23456789abcdefp-3L, make_ti(0x0LL, 0x0LL)))
59 return 1;
60 if (test__fixtfti(0x1.23456789abcdef12345678p+20L,
61 make_ti(0x0LL, 0x123456LL)))
62 return 1;
63 if (test__fixtfti(0x1.23456789abcdef123456789abcdep+112L,
64 make_ti(0x123456789abcdLL, 0xef123456789abcdeLL)))
65 return 1;
66 if (test__fixtfti(-0x1.23456789abcdef123456789abcdep+112L,
67 make_ti(0xFFFEDCBA98765432LL, 0x10EDCBA987654322LL)))
68 return 1;
69 if (test__fixtfti(0x1.23456789abcdefp+256L, make_ti(0x7fffffffffffffffLL,
70 0xffffffffffffffffLL)))
71 return 1;
72 if (test__fixtfti(-0x1.23456789abcdefp+20L, make_ti(0xffffffffffffffffLL,
73 0xffffffffffedcbaaLL)))
74 return 1;
75 if (test__fixtfti(-0x1.23456789abcdefp+256L, make_ti(0x8000000000000000LL,
76 0x0)))
77 return 1;
79 #else
80 printf("skipped\n");
82 #endif
83 return 0;