Hex Artifact Content
Not logged in

Artifact 51b87984adc0bdde81e8b9f487b53a67d8f670b3:


0000: 2f 2a 20 3d 3d 3d 2d 2d 20 63 6c 7a 64 69 32 2e  /* ===-- clzdi2.
0010: 63 20 2d 20 49 6d 70 6c 65 6d 65 6e 74 20 5f 5f  c - Implement __
0020: 63 6c 7a 64 69 32 20 2d 2d 2d 2d 2d 2d 2d 2d 2d  clzdi2 ---------
0030: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0040: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 3d 3d 3d 0a  ------------===.
0050: 20 2a 0a 20 2a 20 20 20 20 20 20 20 20 20 20 20   *. *           
0060: 20 20 20 20 54 68 65 20 4c 4c 56 4d 20 43 6f 6d      The LLVM Com
0070: 70 69 6c 65 72 20 49 6e 66 72 61 73 74 72 75 63  piler Infrastruc
0080: 74 75 72 65 0a 20 2a 0a 20 2a 20 54 68 69 73 20  ture. *. * This 
0090: 66 69 6c 65 20 69 73 20 64 75 61 6c 20 6c 69 63  file is dual lic
00a0: 65 6e 73 65 64 20 75 6e 64 65 72 20 74 68 65 20  ensed under the 
00b0: 4d 49 54 20 61 6e 64 20 74 68 65 20 55 6e 69 76  MIT and the Univ
00c0: 65 72 73 69 74 79 20 6f 66 20 49 6c 6c 69 6e 6f  ersity of Illino
00d0: 69 73 20 4f 70 65 6e 0a 20 2a 20 53 6f 75 72 63  is Open. * Sourc
00e0: 65 20 4c 69 63 65 6e 73 65 73 2e 20 53 65 65 20  e Licenses. See 
00f0: 4c 49 43 45 4e 53 45 2e 54 58 54 20 66 6f 72 20  LICENSE.TXT for 
0100: 64 65 74 61 69 6c 73 2e 0a 20 2a 0a 20 2a 20 3d  details.. *. * =
0110: 3d 3d 2d 2d 2d 2d 2d 2d 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 3d 3d 3d 0a 20 2a 0a 20  --------===. *. 
0160: 2a 20 54 68 69 73 20 66 69 6c 65 20 69 6d 70 6c  * This file impl
0170: 65 6d 65 6e 74 73 20 5f 5f 63 6c 7a 64 69 32 20  ements __clzdi2 
0180: 66 6f 72 20 74 68 65 20 63 6f 6d 70 69 6c 65 72  for the compiler
0190: 5f 72 74 20 6c 69 62 72 61 72 79 2e 0a 20 2a 0a  _rt library.. *.
01a0: 20 2a 20 3d 3d 3d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d   * ===----------
01b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
01c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
01d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
01e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 3d 3d 3d 0a  ------------===.
01f0: 20 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 22 69   */..#include "i
0200: 6e 74 5f 6c 69 62 2e 68 22 0a 0a 2f 2a 20 52 65  nt_lib.h"../* Re
0210: 74 75 72 6e 73 3a 20 74 68 65 20 6e 75 6d 62 65  turns: the numbe
0220: 72 20 6f 66 20 6c 65 61 64 69 6e 67 20 30 2d 62  r of leading 0-b
0230: 69 74 73 20 2a 2f 0a 0a 2f 2a 20 50 72 65 63 6f  its */../* Preco
0240: 6e 64 69 74 69 6f 6e 3a 20 61 20 21 3d 20 30 20  ndition: a != 0 
0250: 2a 2f 0a 0a 43 4f 4d 50 49 4c 45 52 5f 52 54 5f  */..COMPILER_RT_
0260: 41 42 49 20 73 69 5f 69 6e 74 0a 5f 5f 63 6c 7a  ABI si_int.__clz
0270: 64 69 32 28 64 69 5f 69 6e 74 20 61 29 0a 7b 0a  di2(di_int a).{.
0280: 20 20 20 20 64 77 6f 72 64 73 20 78 3b 0a 20 20      dwords x;.  
0290: 20 20 78 2e 61 6c 6c 20 3d 20 61 3b 0a 20 20 20    x.all = a;.   
02a0: 20 63 6f 6e 73 74 20 73 69 5f 69 6e 74 20 66 20   const si_int f 
02b0: 3d 20 2d 28 78 2e 73 2e 68 69 67 68 20 3d 3d 20  = -(x.s.high == 
02c0: 30 29 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 5f  0);.    return _
02d0: 5f 62 75 69 6c 74 69 6e 5f 63 6c 7a 28 28 78 2e  _builtin_clz((x.
02e0: 73 2e 68 69 67 68 20 26 20 7e 66 29 20 7c 20 28  s.high & ~f) | (
02f0: 78 2e 73 2e 6c 6f 77 20 26 20 66 29 29 20 2b 0a  x.s.low & f)) +.
0300: 20 20 20 20 20 20 20 20 20 20 20 28 66 20 26 20             (f & 
0310: 28 28 73 69 5f 69 6e 74 29 28 73 69 7a 65 6f 66  ((si_int)(sizeof
0320: 28 73 69 5f 69 6e 74 29 20 2a 20 43 48 41 52 5f  (si_int) * CHAR_
0330: 42 49 54 29 29 29 3b 0a 7d 0a                    BIT)));.}.