Hex Artifact Content
Not logged in

Artifact 65d3df612fbf96f92a7eb384967f8cd331c9ba4f:


0000: 2f 2f 3d 3d 3d 2d 2d 20 6c 69 62 2f 66 6c 6f 61  //===-- lib/floa
0010: 74 75 6e 64 69 74 66 2e 63 20 2d 20 75 69 6e 74  tunditf.c - uint
0020: 20 2d 3e 20 71 75 61 64 2d 70 72 65 63 69 73 69   -> quad-precisi
0030: 6f 6e 20 63 6f 6e 76 65 72 73 69 6f 6e 20 2d 2d  on conversion --
0040: 2d 2d 2d 2a 2d 20 43 20 2d 2a 2d 3d 3d 3d 2f 2f  ---*- C -*-===//
0050: 0a 2f 2f 0a 2f 2f 20 20 20 20 20 20 20 20 20 20  .//.//          
0060: 20 20 20 20 20 20 20 20 20 20 20 54 68 65 20 4c             The L
0070: 4c 56 4d 20 43 6f 6d 70 69 6c 65 72 20 49 6e 66  LVM Compiler Inf
0080: 72 61 73 74 72 75 63 74 75 72 65 0a 2f 2f 0a 2f  rastructure.//./
0090: 2f 20 54 68 69 73 20 66 69 6c 65 20 69 73 20 64  / This file is d
00a0: 75 61 6c 20 6c 69 63 65 6e 73 65 64 20 75 6e 64  ual licensed und
00b0: 65 72 20 74 68 65 20 4d 49 54 20 61 6e 64 20 74  er the MIT and t
00c0: 68 65 20 55 6e 69 76 65 72 73 69 74 79 20 6f 66  he University of
00d0: 20 49 6c 6c 69 6e 6f 69 73 20 4f 70 65 6e 0a 2f   Illinois Open./
00e0: 2f 20 53 6f 75 72 63 65 20 4c 69 63 65 6e 73 65  / Source License
00f0: 73 2e 20 53 65 65 20 4c 49 43 45 4e 53 45 2e 54  s. See LICENSE.T
0100: 58 54 20 66 6f 72 20 64 65 74 61 69 6c 73 2e 0a  XT for details..
0110: 2f 2f 0a 2f 2f 3d 3d 3d 2d 2d 2d 2d 2d 2d 2d 2d  //.//===--------
0120: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0130: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0140: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0150: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 3d 3d  --------------==
0160: 3d 2f 2f 0a 2f 2f 0a 2f 2f 20 54 68 69 73 20 66  =//.//.// This f
0170: 69 6c 65 20 69 6d 70 6c 65 6d 65 6e 74 73 20 64  ile implements d
0180: 75 5f 69 6e 74 20 74 6f 20 71 75 61 64 2d 70 72  u_int to quad-pr
0190: 65 63 69 73 69 6f 6e 20 63 6f 6e 76 65 72 73 69  ecision conversi
01a0: 6f 6e 20 66 6f 72 20 74 68 65 0a 2f 2f 20 63 6f  on for the.// co
01b0: 6d 70 69 6c 65 72 2d 72 74 20 6c 69 62 72 61 72  mpiler-rt librar
01c0: 79 20 69 6e 20 74 68 65 20 49 45 45 45 2d 37 35  y in the IEEE-75
01d0: 34 20 64 65 66 61 75 6c 74 20 72 6f 75 6e 64 2d  4 default round-
01e0: 74 6f 2d 6e 65 61 72 65 73 74 2c 20 74 69 65 73  to-nearest, ties
01f0: 2d 74 6f 2d 65 76 65 6e 0a 2f 2f 20 6d 6f 64 65  -to-even.// mode
0200: 2e 0a 2f 2f 0a 2f 2f 3d 3d 3d 2d 2d 2d 2d 2d 2d  ..//.//===------
0210: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0220: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0230: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0240: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0250: 3d 3d 3d 2f 2f 0a 0a 23 64 65 66 69 6e 65 20 51  ===//..#define Q
0260: 55 41 44 5f 50 52 45 43 49 53 49 4f 4e 0a 23 69  UAD_PRECISION.#i
0270: 6e 63 6c 75 64 65 20 22 66 70 5f 6c 69 62 2e 68  nclude "fp_lib.h
0280: 22 0a 0a 23 69 66 20 64 65 66 69 6e 65 64 28 43  "..#if defined(C
0290: 52 54 5f 48 41 53 5f 31 32 38 42 49 54 29 20 26  RT_HAS_128BIT) &
02a0: 26 20 64 65 66 69 6e 65 64 28 43 52 54 5f 4c 44  & defined(CRT_LD
02b0: 42 4c 5f 31 32 38 42 49 54 29 0a 43 4f 4d 50 49  BL_128BIT).COMPI
02c0: 4c 45 52 5f 52 54 5f 41 42 49 20 66 70 5f 74 20  LER_RT_ABI fp_t 
02d0: 5f 5f 66 6c 6f 61 74 75 6e 64 69 74 66 28 64 75  __floatunditf(du
02e0: 5f 69 6e 74 20 61 29 20 7b 0a 0a 20 20 20 20 63  _int a) {..    c
02f0: 6f 6e 73 74 20 69 6e 74 20 61 57 69 64 74 68 20  onst int aWidth 
0300: 3d 20 73 69 7a 65 6f 66 20 61 20 2a 20 43 48 41  = sizeof a * CHA
0310: 52 5f 42 49 54 3b 0a 0a 20 20 20 20 2f 2f 20 48  R_BIT;..    // H
0320: 61 6e 64 6c 65 20 7a 65 72 6f 20 61 73 20 61 20  andle zero as a 
0330: 73 70 65 63 69 61 6c 20 63 61 73 65 20 74 6f 20  special case to 
0340: 70 72 6f 74 65 63 74 20 63 6c 7a 0a 20 20 20 20  protect clz.    
0350: 69 66 20 28 61 20 3d 3d 20 30 29 20 72 65 74 75  if (a == 0) retu
0360: 72 6e 20 66 72 6f 6d 52 65 70 28 30 29 3b 0a 0a  rn fromRep(0);..
0370: 20 20 20 20 2f 2f 20 45 78 70 6f 6e 65 6e 74 20      // Exponent 
0380: 6f 66 20 28 66 70 5f 74 29 61 20 69 73 20 74 68  of (fp_t)a is th
0390: 65 20 77 69 64 74 68 20 6f 66 20 61 62 73 28 61  e width of abs(a
03a0: 29 2e 0a 20 20 20 20 63 6f 6e 73 74 20 69 6e 74  )..    const int
03b0: 20 65 78 70 6f 6e 65 6e 74 20 3d 20 28 61 57 69   exponent = (aWi
03c0: 64 74 68 20 2d 20 31 29 20 2d 20 5f 5f 62 75 69  dth - 1) - __bui
03d0: 6c 74 69 6e 5f 63 6c 7a 6c 6c 28 61 29 3b 0a 20  ltin_clzll(a);. 
03e0: 20 20 20 72 65 70 5f 74 20 72 65 73 75 6c 74 3b     rep_t result;
03f0: 0a 0a 20 20 20 20 2f 2f 20 53 68 69 66 74 20 61  ..    // Shift a
0400: 20 69 6e 74 6f 20 74 68 65 20 73 69 67 6e 69 66   into the signif
0410: 69 63 61 6e 64 20 66 69 65 6c 64 20 61 6e 64 20  icand field and 
0420: 63 6c 65 61 72 20 74 68 65 20 69 6d 70 6c 69 63  clear the implic
0430: 69 74 20 62 69 74 2e 0a 20 20 20 20 63 6f 6e 73  it bit..    cons
0440: 74 20 69 6e 74 20 73 68 69 66 74 20 3d 20 73 69  t int shift = si
0450: 67 6e 69 66 69 63 61 6e 64 42 69 74 73 20 2d 20  gnificandBits - 
0460: 65 78 70 6f 6e 65 6e 74 3b 0a 20 20 20 20 72 65  exponent;.    re
0470: 73 75 6c 74 20 3d 20 28 72 65 70 5f 74 29 61 20  sult = (rep_t)a 
0480: 3c 3c 20 73 68 69 66 74 20 5e 20 69 6d 70 6c 69  << shift ^ impli
0490: 63 69 74 42 69 74 3b 0a 0a 20 20 20 20 2f 2f 20  citBit;..    // 
04a0: 49 6e 73 65 72 74 20 74 68 65 20 65 78 70 6f 6e  Insert the expon
04b0: 65 6e 74 0a 20 20 20 20 72 65 73 75 6c 74 20 2b  ent.    result +
04c0: 3d 20 28 72 65 70 5f 74 29 28 65 78 70 6f 6e 65  = (rep_t)(expone
04d0: 6e 74 20 2b 20 65 78 70 6f 6e 65 6e 74 42 69 61  nt + exponentBia
04e0: 73 29 20 3c 3c 20 73 69 67 6e 69 66 69 63 61 6e  s) << significan
04f0: 64 42 69 74 73 3b 0a 20 20 20 20 72 65 74 75 72  dBits;.    retur
0500: 6e 20 66 72 6f 6d 52 65 70 28 72 65 73 75 6c 74  n fromRep(result
0510: 29 3b 0a 7d 0a 0a 23 65 6e 64 69 66 0a           );.}..#endif.