60 lines · c
1// REQUIRES: target-is-powerpc64le2// RUN: %clang_builtins %s %librt -o %t && %run %t3 4/*5 * Test case execution for: long double __floattitf (__int128_t)6 * Conversion from 128 bit integer to long double (IBM double-double).7 */8 9#include <stdint.h>10#include <stdio.h>11 12#include "floattitf_test.h"13 14/* The long double representation, with the high and low portions of15 * the long double, and the corresponding bit patterns of each double. */16typedef union {17 long double ld;18 double d[2]; /* [0] is the high double, [1] is the low double. */19 unsigned long long ull[2]; /* High and low doubles as 64-bit integers. */20} ldUnion;21 22long double __floattitf(__int128_t);23 24int main(int argc, char *argv[]) {25 /* Necessary long double and 128 bit integer declarations used to26 * compare computed and expected high and low portions of the27 * IBM double-double. */28 ldUnion expectedLongDouble;29 ldUnion computedLongDouble;30 __int128_t result128;31 32 for (int i = 0; i < numTests; ++i) {33 /* Set the expected high and low values of the long double,34 * and the 128 bit integer input to be converted. */35 expectedLongDouble.d[0] = tests[i].hi;36 expectedLongDouble.d[1] = tests[i].lo;37 result128 = tests[i].input128;38 39 /* Get the computed long double from the int128->long double conversion40 * and check for errors between high and low portions. */41 computedLongDouble.ld = __floattitf(result128);42 43 if ((computedLongDouble.d[0] != expectedLongDouble.d[0]) ||44 (computedLongDouble.d[1] != expectedLongDouble.d[1])) {45 46 printf("Error on __floattitf( 0x%016llx 0x%016llx ):\n",47 (long long)(tests[i].input128 >> 64),48 (long long)tests[i].input128);49 printf("\tExpected value - %La = ( %a, %a )\n", expectedLongDouble.ld,50 expectedLongDouble.d[0], expectedLongDouble.d[1]);51 printf("\tComputed value - %La = ( %a, %a )\n\n", computedLongDouble.ld,52 computedLongDouble.d[0], computedLongDouble.d[1]);53 54 return 1;55 }56 }57 58 return 0;59}60