value: lower_case
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: "^_[A-Za-z0-9_]+$"
+ - key: readability-identifier-naming.GlobalConstantCase
+ value: UPPER_CASE
- key: readability-identifier-naming.ConstexprVariableCase
value: UPPER_CASE
- key: readability-identifier-naming.GetConfigPerFile
sizeof(fenv_t) == sizeof(FPState),
"Internal floating point state does not match the public fenv_t type.");
- static constexpr uint32_t ToNearest = 0x0;
- static constexpr uint32_t Upward = 0x1;
- static constexpr uint32_t Downward = 0x2;
- static constexpr uint32_t TowardZero = 0x3;
+ static constexpr uint32_t TONEAREST = 0x0;
+ static constexpr uint32_t UPWARD = 0x1;
+ static constexpr uint32_t DOWNWARD = 0x2;
+ static constexpr uint32_t TOWARDZERO = 0x3;
- static constexpr uint32_t Invalid = 0x1;
- static constexpr uint32_t DivByZero = 0x2;
- static constexpr uint32_t Overflow = 0x4;
- static constexpr uint32_t Underflow = 0x8;
- static constexpr uint32_t Inexact = 0x10;
+ static constexpr uint32_t INVALID = 0x1;
+ static constexpr uint32_t DIVBYZERO = 0x2;
+ static constexpr uint32_t OVERFLOW = 0x4;
+ static constexpr uint32_t UNDERFLOW = 0x8;
+ static constexpr uint32_t INEXACT = 0x10;
// Zero-th bit is the first bit.
static constexpr uint32_t RoundingControlBitPosition = 22;
static constexpr uint32_t ExceptionControlFlagsBitPosition = 8;
static inline uint32_t getStatusValueForExcept(int excepts) {
- return (excepts & FE_INVALID ? Invalid : 0) |
- (excepts & FE_DIVBYZERO ? DivByZero : 0) |
- (excepts & FE_OVERFLOW ? Overflow : 0) |
- (excepts & FE_UNDERFLOW ? Underflow : 0) |
- (excepts & FE_INEXACT ? Inexact : 0);
+ return (excepts & FE_INVALID ? INVALID : 0) |
+ (excepts & FE_DIVBYZERO ? DIVBYZERO : 0) |
+ (excepts & FE_OVERFLOW ? OVERFLOW : 0) |
+ (excepts & FE_UNDERFLOW ? UNDERFLOW : 0) |
+ (excepts & FE_INEXACT ? INEXACT : 0);
}
static inline int exceptionStatusToMacro(uint32_t status) {
- return (status & Invalid ? FE_INVALID : 0) |
- (status & DivByZero ? FE_DIVBYZERO : 0) |
- (status & Overflow ? FE_OVERFLOW : 0) |
- (status & Underflow ? FE_UNDERFLOW : 0) |
- (status & Inexact ? FE_INEXACT : 0);
+ return (status & INVALID ? FE_INVALID : 0) |
+ (status & DIVBYZERO ? FE_DIVBYZERO : 0) |
+ (status & OVERFLOW ? FE_OVERFLOW : 0) |
+ (status & UNDERFLOW ? FE_UNDERFLOW : 0) |
+ (status & INEXACT ? FE_INEXACT : 0);
}
static uint32_t getControlWord() { return __arm_rsr("fpcr"); }
uint32_t toRaise = FEnv::getStatusValueForExcept(excepts);
- if (toRaise & FEnv::Invalid) {
+ if (toRaise & FEnv::INVALID) {
divfunc(zero, zero);
uint32_t statusWord = FEnv::getStatusWord();
if (!((statusWord >> FEnv::ExceptionStatusFlagsBitPosition) &
- FEnv::Invalid))
+ FEnv::INVALID))
return -1;
}
- if (toRaise & FEnv::DivByZero) {
+ if (toRaise & FEnv::DIVBYZERO) {
divfunc(one, zero);
uint32_t statusWord = FEnv::getStatusWord();
if (!((statusWord >> FEnv::ExceptionStatusFlagsBitPosition) &
- FEnv::DivByZero))
+ FEnv::DIVBYZERO))
return -1;
}
- if (toRaise & FEnv::Overflow) {
+ if (toRaise & FEnv::OVERFLOW) {
divfunc(largeValue, smallValue);
uint32_t statusWord = FEnv::getStatusWord();
if (!((statusWord >> FEnv::ExceptionStatusFlagsBitPosition) &
- FEnv::Overflow))
+ FEnv::OVERFLOW))
return -1;
}
- if (toRaise & FEnv::Underflow) {
+ if (toRaise & FEnv::UNDERFLOW) {
divfunc(smallValue, largeValue);
uint32_t statusWord = FEnv::getStatusWord();
if (!((statusWord >> FEnv::ExceptionStatusFlagsBitPosition) &
- FEnv::Underflow))
+ FEnv::UNDERFLOW))
return -1;
}
- if (toRaise & FEnv::Inexact) {
+ if (toRaise & FEnv::INEXACT) {
float two = 2.0f;
float three = 3.0f;
// 2.0 / 3.0 cannot be represented exactly in any radix 2 floating point
divfunc(two, three);
uint32_t statusWord = FEnv::getStatusWord();
if (!((statusWord >> FEnv::ExceptionStatusFlagsBitPosition) &
- FEnv::Inexact))
+ FEnv::INEXACT))
return -1;
}
return 0;
uint32_t roundingMode =
(FEnv::getControlWord() >> FEnv::RoundingControlBitPosition) & 0x3;
switch (roundingMode) {
- case FEnv::ToNearest:
+ case FEnv::TONEAREST:
return FE_TONEAREST;
- case FEnv::Downward:
+ case FEnv::DOWNWARD:
return FE_DOWNWARD;
- case FEnv::Upward:
+ case FEnv::UPWARD:
return FE_UPWARD;
- case FEnv::TowardZero:
+ case FEnv::TOWARDZERO:
return FE_TOWARDZERO;
default:
return -1; // Error value.
uint16_t bitValue;
switch (mode) {
case FE_TONEAREST:
- bitValue = FEnv::ToNearest;
+ bitValue = FEnv::TONEAREST;
break;
case FE_DOWNWARD:
- bitValue = FEnv::Downward;
+ bitValue = FEnv::DOWNWARD;
break;
case FE_UPWARD:
- bitValue = FEnv::Upward;
+ bitValue = FEnv::UPWARD;
break;
case FE_TOWARDZERO:
- bitValue = FEnv::TowardZero;
+ bitValue = FEnv::TOWARDZERO;
break;
default:
return 1; // To indicate failure
double x = y;
double s;
int n;
- const sincos_t *p = &__SINCOSF_TABLE[0];
+ const sincos_t *p = &SINCOSF_TABLE[0];
- if (abstop12(y) < abstop12(pio4)) {
+ if (abstop12(y) < abstop12(PIO4)) {
double x2 = x * x;
if (unlikely(abstop12(y) < abstop12(as_float(0x39800000))))
s = p->sign[n & 3];
if (n & 2)
- p = &__SINCOSF_TABLE[1];
+ p = &SINCOSF_TABLE[1];
return sinf_poly(x * s, x * x, p, n ^ 1);
} else if (abstop12(y) < abstop12(INFINITY)) {
s = p->sign[(n + sign) & 3];
if ((n + sign) & 2)
- p = &__SINCOSF_TABLE[1];
+ p = &SINCOSF_TABLE[1];
return sinf_poly(x * s, x * x, p, n ^ 1);
}
namespace __llvm_libc {
-constexpr float XFlowValues<float>::overflow_value = 0x1p97f;
-constexpr float XFlowValues<float>::underflow_value = 0x1p-95f;
-constexpr float XFlowValues<float>::may_underflow_value = 0x1.4p-75f;
+constexpr float XFlowValues<float>::OVERFLOW_VALUE = 0x1p97f;
+constexpr float XFlowValues<float>::UNDERFLOW_VALUE = 0x1p-95f;
+constexpr float XFlowValues<float>::MAY_UNDERFLOW_VALUE = 0x1.4p-75f;
-constexpr double XFlowValues<double>::overflow_value = 0x1p769;
-constexpr double XFlowValues<double>::underflow_value = 0x1p-767;
-constexpr double XFlowValues<double>::may_underflow_value = 0x1.8p-538;
+constexpr double XFlowValues<double>::OVERFLOW_VALUE = 0x1p769;
+constexpr double XFlowValues<double>::UNDERFLOW_VALUE = 0x1p-767;
+constexpr double XFlowValues<double>::MAY_UNDERFLOW_VALUE = 0x1.8p-538;
} // namespace __llvm_libc
template <typename T> struct XFlowValues;
template <> struct XFlowValues<float> {
- static const float overflow_value;
- static const float underflow_value;
- static const float may_underflow_value;
+ static const float OVERFLOW_VALUE;
+ static const float UNDERFLOW_VALUE;
+ static const float MAY_UNDERFLOW_VALUE;
};
template <> struct XFlowValues<double> {
- static const double overflow_value;
- static const double underflow_value;
- static const double may_underflow_value;
+ static const double OVERFLOW_VALUE;
+ static const double UNDERFLOW_VALUE;
+ static const double MAY_UNDERFLOW_VALUE;
};
template <typename T> static inline T with_errno(T x, int err) {
}
template <typename T, EnableIfFloatOrDouble<T> = 0> T overflow(uint32_t sign) {
- return xflow(sign, XFlowValues<T>::overflow_value);
+ return xflow(sign, XFlowValues<T>::OVERFLOW_VALUE);
}
template <typename T, EnableIfFloatOrDouble<T> = 0> T underflow(uint32_t sign) {
- return xflow(sign, XFlowValues<T>::underflow_value);
+ return xflow(sign, XFlowValues<T>::UNDERFLOW_VALUE);
}
template <typename T, EnableIfFloatOrDouble<T> = 0>
T may_underflow(uint32_t sign) {
- return xflow(sign, XFlowValues<T>::may_underflow_value);
+ return xflow(sign, XFlowValues<T>::MAY_UNDERFLOW_VALUE);
}
template <typename T, EnableIfFloatOrDouble<T> = 0>
double x = y;
double s;
int n;
- const sincos_t *p = &__SINCOSF_TABLE[0];
+ const sincos_t *p = &SINCOSF_TABLE[0];
- if (abstop12(y) < abstop12(pio4)) {
+ if (abstop12(y) < abstop12(PIO4)) {
double x2 = x * x;
if (unlikely(abstop12(y) < abstop12(as_float(0x39800000)))) {
s = p->sign[n & 3];
if (n & 2)
- p = &__SINCOSF_TABLE[1];
+ p = &SINCOSF_TABLE[1];
sincosf_poly(x * s, x * x, p, n, sinp, cosp);
} else if (likely(abstop12(y) < abstop12(INFINITY))) {
s = p->sign[(n + sign) & 3];
if ((n + sign) & 2)
- p = &__SINCOSF_TABLE[1];
+ p = &SINCOSF_TABLE[1];
sincosf_poly(x * s, x * x, p, n, sinp, cosp);
} else {
// The constants and polynomials for sine and cosine. The 2nd entry
// computes -cos (x) rather than cos (x) to get negation for free.
-constexpr sincos_t __SINCOSF_TABLE[2] = {
+constexpr sincos_t SINCOSF_TABLE[2] = {
{{1.0, -1.0, -1.0, 1.0},
0x1.45f306dc9c883p+23,
0x1.921fb54442d18p+0,
// Table with 4/PI to 192 bit precision. To avoid unaligned accesses
// only 8 new bits are added per entry, making the table 4 times larger.
-constexpr uint32_t __INV_PIO4[24] = {
+constexpr uint32_t INV_PIO4[24] = {
0xa2, 0xa2f9, 0xa2f983, 0xa2f9836e, 0xf9836e4e, 0x836e4e44,
0x6e4e4415, 0x4e441529, 0x441529fc, 0x1529fc27, 0x29fc2757, 0xfc2757d1,
0x2757d1f5, 0x57d1f534, 0xd1f534dd, 0xf534ddc0, 0x34ddc0db, 0xddc0db62,
namespace __llvm_libc {
// 2PI * 2^-64.
-static constexpr double pi63 = 0x1.921fb54442d18p-62;
+static constexpr double PI63 = 0x1.921fb54442d18p-62;
// PI / 4.
-static constexpr double pio4 = 0x1.921fb54442d18p-1;
+static constexpr double PIO4 = 0x1.921fb54442d18p-1;
// The constants and polynomials for sine and cosine.
typedef struct {
} sincos_t;
// Polynomial data (the cosine polynomial is negated in the 2nd entry).
-extern const sincos_t __SINCOSF_TABLE[2];
+extern const sincos_t SINCOSF_TABLE[2];
// Table with 4/PI to 192 bit precision.
-extern const uint32_t __INV_PIO4[];
+extern const uint32_t INV_PIO4[];
// Top 12 bits of the float representation with the sign bit cleared.
static inline uint32_t abstop12(float x) {
// can have at most 29 leading zeros after the binary point, the double
// precision result is accurate to 33 bits.
static inline double reduce_large(uint32_t xi, int *np) {
- const uint32_t *arr = &__INV_PIO4[(xi >> 26) & 15];
+ const uint32_t *arr = &INV_PIO4[(xi >> 26) & 15];
int shift = (xi >> 23) & 7;
uint64_t n, res0, res1, res2;
res0 -= n << 62;
double x = (int64_t)res0;
*np = n;
- return x * pi63;
+ return x * PI63;
}
} // namespace __llvm_libc
double x = y;
double s;
int n;
- const sincos_t *p = &__SINCOSF_TABLE[0];
+ const sincos_t *p = &SINCOSF_TABLE[0];
- if (abstop12(y) < abstop12(pio4)) {
+ if (abstop12(y) < abstop12(PIO4)) {
s = x * x;
if (unlikely(abstop12(y) < abstop12(as_float(0x39800000)))) {
s = p->sign[n & 3];
if (n & 2)
- p = &__SINCOSF_TABLE[1];
+ p = &SINCOSF_TABLE[1];
return sinf_poly(x * s, x * x, p, n);
} else if (abstop12(y) < abstop12(INFINITY)) {
s = p->sign[(n + sign) & 3];
if ((n + sign) & 2)
- p = &__SINCOSF_TABLE[1];
+ p = &SINCOSF_TABLE[1];
return sinf_poly(x * s, x * x, p, n);
}