[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / ppc / fixtfti_test.c
blob8b86d7879f7e7269a73af9623a959fe78eb2a6ca
1 // REQUIRES: target-is-powerpc64le
2 // RUN: %clang_builtins %s %librt -o %t && %run %t
4 #include <stdint.h>
5 #include <stdio.h>
7 #include "fixtfti_test.h"
9 // The long double representation, with the high and low portions of
10 // the long double, and the corresponding bit patterns of each double.
11 typedef union {
12 long double ld;
13 double d[2]; // [0] is the high double, [1] is the low double.
14 unsigned long long ull[2]; // High and low doubles as 64-bit integers.
15 } ldUnion;
17 __int128_t __fixtfti(long double);
19 int main(int argc, char *argv[]) {
20 // Necessary long double and (unsigned) 128 bit integer
21 // declarations used to compare the computed and expected results
22 // from converting the IBM double-double to int128.
23 ldUnion ldInput;
24 __uint128_t expectedResult, computedResult;
26 for (int i = 0; i < numTests; ++i) {
27 // Set the expected 128 bit integer and the high and low
28 // values of the long double input.
29 ldInput.d[0] = testList[i].hiInput;
30 ldInput.d[1] = testList[i].loInput;
31 expectedResult = testList[i].result128;
33 // Get the computed 128 bit integer from the long double to
34 // int128 conversion. Here we cast to unsigned int128 to
35 // get the bit pattern of the result.
36 computedResult = (__uint128_t) __fixtfti(ldInput.ld);
38 if (computedResult != expectedResult) {
39 printf("Error for __fixtfti at input %La = ( %a , %a ):\n", ldInput.ld,
40 ldInput.d[0], ldInput.d[1]);
41 printf("\tExpected __int128_t: 0x%016llx 0x%016llx\n",
42 (unsigned long long)(expectedResult >> 64),
43 (unsigned long long)expectedResult);
44 printf("\tComputed __int128_t: 0x%016llx 0x%016llx\n\n",
45 (unsigned long long)(computedResult >> 64),
46 (unsigned long long)computedResult);
48 return 1;
52 return 0;