PostgreSQL Source Code  git master
d2s_intrinsics.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static uint64 umul128 (const uint64 a, const uint64 b, uint64 *const productHi)
 
static uint64 shiftright128 (const uint64 lo, const uint64 hi, const uint32 dist)
 
static uint64 div5 (const uint64 x)
 
static uint64 div10 (const uint64 x)
 
static uint64 div100 (const uint64 x)
 
static uint64 div1e8 (const uint64 x)
 

Function Documentation

◆ div10()

static uint64 div10 ( const uint64  x)
inlinestatic

Definition at line 183 of file d2s_intrinsics.h.

184 {
185  return x / 10;
186 }
int x
Definition: isn.c:71

References x.

Referenced by d2d(), and to_chars().

◆ div100()

static uint64 div100 ( const uint64  x)
inlinestatic

Definition at line 189 of file d2s_intrinsics.h.

190 {
191  return x / 100;
192 }

References x.

Referenced by d2d().

◆ div1e8()

static uint64 div1e8 ( const uint64  x)
inlinestatic

Definition at line 195 of file d2s_intrinsics.h.

196 {
197  return x / 100000000;
198 }

References x.

Referenced by to_chars(), and to_chars_df().

◆ div5()

static uint64 div5 ( const uint64  x)
inlinestatic

Definition at line 177 of file d2s_intrinsics.h.

178 {
179  return x / 5;
180 }

References x.

Referenced by d2d(), and pow5Factor().

◆ shiftright128()

static uint64 shiftright128 ( const uint64  lo,
const uint64  hi,
const uint32  dist 
)
inlinestatic

Definition at line 100 of file d2s_intrinsics.h.

101 {
102  /* We don't need to handle the case dist >= 64 here (see above). */
103  Assert(dist < 64);
104 #if !defined(RYU_32_BIT_PLATFORM)
105  Assert(dist > 0);
106  return (hi << (64 - dist)) | (lo >> dist);
107 #else
108  /* Avoid a 64-bit shift by taking advantage of the range of shift values. */
109  Assert(dist >= 32);
110  return (hi << (64 - dist)) | ((uint32) (lo >> 32) >> (dist - 32));
111 #endif
112 }
unsigned int uint32
Definition: c.h:441
Assert(fmt[strlen(fmt) - 1] !='\n')

References Assert().

Referenced by mulShiftAll().

◆ umul128()

static uint64 umul128 ( const uint64  a,
const uint64  b,
uint64 *const  productHi 
)
inlinestatic

Definition at line 65 of file d2s_intrinsics.h.

66 {
67  /*
68  * The casts here help MSVC to avoid calls to the __allmul library
69  * function.
70  */
71  const uint32 aLo = (uint32) a;
72  const uint32 aHi = (uint32) (a >> 32);
73  const uint32 bLo = (uint32) b;
74  const uint32 bHi = (uint32) (b >> 32);
75 
76  const uint64 b00 = (uint64) aLo * bLo;
77  const uint64 b01 = (uint64) aLo * bHi;
78  const uint64 b10 = (uint64) aHi * bLo;
79  const uint64 b11 = (uint64) aHi * bHi;
80 
81  const uint32 b00Lo = (uint32) b00;
82  const uint32 b00Hi = (uint32) (b00 >> 32);
83 
84  const uint64 mid1 = b10 + b00Hi;
85  const uint32 mid1Lo = (uint32) (mid1);
86  const uint32 mid1Hi = (uint32) (mid1 >> 32);
87 
88  const uint64 mid2 = b01 + mid1Lo;
89  const uint32 mid2Lo = (uint32) (mid2);
90  const uint32 mid2Hi = (uint32) (mid2 >> 32);
91 
92  const uint64 pHi = b11 + mid1Hi + mid2Hi;
93  const uint64 pLo = ((uint64) mid2Lo << 32) + b00Lo;
94 
95  *productHi = pHi;
96  return pLo;
97 }
int b
Definition: isn.c:70
int a
Definition: isn.c:69

References a, and b.

Referenced by mulShiftAll().