Skip to content

Commit e441974

Browse files
committed
Merge remote-tracking branch 'origin/main' into lv-vectorize-fmaxnum-without-fmfs
2 parents bfe6853 + a676ecd commit e441974

File tree

24 files changed

+448
-186
lines changed

24 files changed

+448
-186
lines changed

flang/test/Semantics/PowerPC/ppc-vector-types01.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
! RUN: %flang_fc1 -fdebug-unparse %s | FileCheck %s
22
! REQUIRES: target=powerpc{{.*}}
33

4-
! CHECK-LABEL: PROGRAM ppc_vec_unit
4+
! CHECK-LABEL: PROGRAM PPC_VEC_UNIT
55
program ppc_vec_unit
66
implicit none
77
! CHECK: VECTOR(INTEGER(KIND=4_4)) :: vi1, vi2

flang/test/Semantics/PowerPC/ppc-vector-types02.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
! REQUIRES: target=powerpc{{.*}}
33

44
! C: MainProgram scope: ppc_vec_types
5-
! CHECK-LABEL: MainProgram scope: ppc_vec_types size={{[0-9]*}} alignment={{[0-9]*}}
5+
! CHECK-LABEL: MainProgram scope: PPC_VEC_TYPES size={{[0-9]*}} alignment={{[0-9]*}}
66
program ppc_vec_types
77
implicit none
88
vector(integer(4)) :: vi

libc/include/llvm-libc-macros/math-macros.h

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,105 @@
5050
#define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
5151
#endif
5252

53+
// POSIX math constants
54+
// https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/math.h.html
55+
#define M_E (__extension__ 0x1.5bf0a8b145769p1)
56+
#define M_EGAMMA (__extension__ 0x1.2788cfc6fb619p-1)
57+
#define M_LOG2E (__extension__ 0x1.71547652b82fep0)
58+
#define M_LOG10E (__extension__ 0x1.bcb7b1526e50ep-2)
59+
#define M_LN2 (__extension__ 0x1.62e42fefa39efp-1)
60+
#define M_LN10 (__extension__ 0x1.26bb1bbb55516p1)
61+
#define M_PHI (__extension__ 0x1.9e3779b97f4a8p0)
62+
#define M_PI (__extension__ 0x1.921fb54442d18p1)
63+
#define M_PI_2 (__extension__ 0x1.921fb54442d18p0)
64+
#define M_PI_4 (__extension__ 0x1.921fb54442d18p-1)
65+
#define M_1_PI (__extension__ 0x1.45f306dc9c883p-2)
66+
#define M_1_SQRTPI (__extension__ 0x1.20dd750429b6dp-1)
67+
#define M_2_PI (__extension__ 0x1.45f306dc9c883p-1)
68+
#define M_2_SQRTPI (__extension__ 0x1.20dd750429b6dp0)
69+
#define M_SQRT2 (__extension__ 0x1.6a09e667f3bcdp0)
70+
#define M_SQRT3 (__extension__ 0x1.bb67ae8584caap0)
71+
#define M_SQRT1_2 (__extension__ 0x1.6a09e667f3bcdp-1)
72+
#define M_SQRT1_3 (__extension__ 0x1.279a74590331cp-1)
73+
74+
#define M_Ef (__extension__ 0x1.5bf0a8p1f)
75+
#define M_EGAMMAf (__extension__ 0x1.2788dp-1f)
76+
#define M_LOG2Ef (__extension__ 0x1.715476p0f)
77+
#define M_LOG10Ef (__extension__ 0x1.bcb7b2p-2f)
78+
#define M_LN2f (__extension__ 0x1.62e43p-1f)
79+
#define M_LN10f (__extension__ 0x1.26bb1cp1f)
80+
#define M_PHIf (__extension__ 0x1.9e377ap0f)
81+
#define M_PIf (__extension__ 0x1.921fb6p1f)
82+
#define M_PI_2f (__extension__ 0x1.921fb6p0f)
83+
#define M_PI_4f (__extension__ 0x1.921fb6p-1f)
84+
#define M_1_PIf (__extension__ 0x1.45f306p-2f)
85+
#define M_1_SQRTPIf (__extension__ 0x1.20dd76p-1f)
86+
#define M_2_PIf (__extension__ 0x1.45f306p-1f)
87+
#define M_2_SQRTPIf (__extension__ 0x1.20dd76p0f)
88+
#define M_SQRT2f (__extension__ 0x1.6a09e6p0f)
89+
#define M_SQRT3f (__extension__ 0x1.bb67aep0f)
90+
#define M_SQRT1_2f (__extension__ 0x1.6a09e6p-1f)
91+
#define M_SQRT1_3f (__extension__ 0x1.279a74p-1f)
92+
93+
#define M_El (__extension__ 0x1.5bf0a8b1457695355fb8ac404e7ap1L)
94+
#define M_EGAMMAl (__extension__ 0x1.2788cfc6fb618f49a37c7f0202a6p-1L)
95+
#define M_LOG2El (__extension__ 0x1.71547652b82fe1777d0ffda0d23ap0L)
96+
#define M_LOG10El (__extension__ 0x1.bcb7b1526e50e32a6ab7555f5a68p-2L)
97+
#define M_LN2l (__extension__ 0x1.62e42fefa39ef35793c7673007e6p-1L)
98+
#define M_LN10l (__extension__ 0x1.26bb1bbb5551582dd4adac5705a6p1L)
99+
#define M_PHIl (__extension__ 0x1.9e3779b97f4a7c15f39cc0605ceep0L)
100+
#define M_PIl (__extension__ 0x1.921fb54442d18469898cc51701b8p1L)
101+
#define M_PI_2l (__extension__ 0x1.921fb54442d18469898cc51701b8p0L)
102+
#define M_PI_4l (__extension__ 0x1.921fb54442d18469898cc51701b8p-1L)
103+
#define M_1_PIl (__extension__ 0x1.45f306dc9c882a53f84eafa3ea6ap-2L)
104+
#define M_1_SQRTPIl (__extension__ 0x1.20dd750429b6d11ae3a914fed7fep-1L)
105+
#define M_2_PIl (__extension__ 0x1.45f306dc9c882a53f84eafa3ea6ap-1L)
106+
#define M_2_SQRTPIl (__extension__ 0x1.20dd750429b6d11ae3a914fed7fep0L)
107+
#define M_SQRT2l (__extension__ 0x1.6a09e667f3bcc908b2fb1366ea95p0L)
108+
#define M_SQRT3l (__extension__ 0x1.bb67ae8584caa73b25742d7078b8p0L)
109+
#define M_SQRT1_2l (__extension__ 0x1.6a09e667f3bcc908b2fb1366ea95p-1L)
110+
#define M_SQRT1_3l (__extension__ 0x1.279a74590331c4d218f81e4afb25p-1L)
111+
112+
#ifdef __FLT16_MANT_DIG__
113+
#define M_Ef16 (__extension__ 0x1.5cp1f16)
114+
#define M_EGAMMAf16 (__extension__ 0x1.278p-1f16)
115+
#define M_LOG2Ef16 (__extension__ 0x1.714f16)
116+
#define M_LOG10Ef16 (__extension__ 0x1.bccp-2f16)
117+
#define M_LN2f16 (__extension__ 0x1.63p-1f16)
118+
#define M_LN10f16 (__extension__ 0x1.26cp1f16)
119+
#define M_PHIf16 (__extension__ 0x1.9e4p0f16)
120+
#define M_PIf16 (__extension__ 0x1.92p1f16)
121+
#define M_PI_2f16 (__extension__ 0x1.92p0f16)
122+
#define M_PI_4f16 (__extension__ 0x1.92p-1f16)
123+
#define M_1_PIf16 (__extension__ 0x1.46p-2f16)
124+
#define M_1_SQRTPIf16 (__extension__ 0x1.20cp-1f16)
125+
#define M_2_PIf16 (__extension__ 0x1.46p-1f16)
126+
#define M_2_SQRTPIf16 (__extension__ 0x1.20cp0f16)
127+
#define M_SQRT2f16 (__extension__ 0x1.6ap0f16)
128+
#define M_SQRT3f16 (__extension__ 0x1.bb8p0f16)
129+
#define M_SQRT1_2f16 (__extension__ 0x1.6ap-1f16)
130+
#define M_SQRT1_3f16 (__extension__ 0x1.278p-1f16)
131+
#endif // __FLT16_MANT_DIG__
132+
133+
#ifdef __SIZEOF_FLOAT128__
134+
#define M_Ef128 (__extension__ 0x1.5bf0a8b1457695355fb8ac404e7ap1q)
135+
#define M_EGAMMAf128 (__extension__ 0x1.2788cfc6fb618f49a37c7f0202a6p-1q)
136+
#define M_LOG2Ef128 (__extension__ 0x1.71547652b82fe1777d0ffda0d23ap0q)
137+
#define M_LOG10Ef128 (__extension__ 0x1.bcb7b1526e50e32a6ab7555f5a68p-2q)
138+
#define M_LN2f128 (__extension__ 0x1.62e42fefa39ef35793c7673007e6p-1q)
139+
#define M_LN10f128 (__extension__ 0x1.26bb1bbb5551582dd4adac5705a6p1q)
140+
#define M_PHIf128 (__extension__ 0x1.9e3779b97f4a7c15f39cc0605ceep0q)
141+
#define M_PIf128 (__extension__ 0x1.921fb54442d18469898cc51701b8p1q)
142+
#define M_PI_2f128 (__extension__ 0x1.921fb54442d18469898cc51701b8p0q)
143+
#define M_PI_4f128 (__extension__ 0x1.921fb54442d18469898cc51701b8p-1q)
144+
#define M_1_PIf128 (__extension__ 0x1.45f306dc9c882a53f84eafa3ea6ap-2q)
145+
#define M_1_SQRTPIf128 (__extension__ 0x1.20dd750429b6d11ae3a914fed7fep-1q)
146+
#define M_2_PIf128 (__extension__ 0x1.45f306dc9c882a53f84eafa3ea6ap-1q)
147+
#define M_2_SQRTPIf128 (__extension__ 0x1.20dd750429b6d11ae3a914fed7fep0q)
148+
#define M_SQRT2f128 (__extension__ 0x1.6a09e667f3bcc908b2fb1366ea95p0q)
149+
#define M_SQRT3f128 (__extension__ 0x1.bb67ae8584caa73b25742d7078b8p0q)
150+
#define M_SQRT1_2f128 (__extension__ 0x1.6a09e667f3bcc908b2fb1366ea95p-1q)
151+
#define M_SQRT1_3f128 (__extension__ 0x1.279a74590331c4d218f81e4afb25p-1q)
152+
#endif // __SIZEOF_FLOAT128__
153+
53154
#endif // LLVM_LIBC_MACROS_MATH_MACROS_H

libc/src/__support/macros/properties/architectures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define LIBC_TARGET_ARCH_IS_GPU
2222
#endif
2323

24-
#if defined(__pnacl__) || defined(__CLR_VER) || defined(LIBC_TARGET_ARCH_IS_GPU)
24+
#if defined(__CLR_VER) || defined(LIBC_TARGET_ARCH_IS_GPU)
2525
#define LIBC_TARGET_ARCH_IS_VM
2626
#endif
2727

libc/test/include/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,21 @@ add_libc_test(
484484
libc.include.llvm-libc-macros.math_function_macros
485485
)
486486

487+
add_libc_test(
488+
math_constants_c_test
489+
C_TEST
490+
UNIT_TEST_ONLY
491+
SUITE
492+
libc_include_tests
493+
SRCS
494+
math_constants_test.c
495+
COMPILE_OPTIONS
496+
-Wall
497+
-Werror
498+
DEPENDS
499+
libc.include.llvm-libc-macros.math_macros
500+
)
501+
487502
# Test `#include <...>` of each header in each available language mode.
488503
# This is gated on -DLLVM_LIBC_BUILD_HEADER_TESTS=ON until all the bugs
489504
# in headers are fixed so the tests all compile.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- Unittests for math constants --------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
#include "include/llvm-libc-macros/math-macros.h"
9+
10+
#define IS_DOUBLE(X) _Generic((X), double: 1, default: 0)
11+
12+
#define IS_FLOAT(X) _Generic((X), float: 1, default: 0)
13+
14+
// check if macro is defined
15+
#ifndef M_PI
16+
#error "M_PI macro is not defined"
17+
#else
18+
int main(void) {
19+
_Static_assert(IS_DOUBLE(M_PI), "M_PI is not of double type.");
20+
_Static_assert(IS_FLOAT(M_PIf), "M_PIf is not of float type.");
21+
return 0;
22+
}
23+
#endif

libcxx/include/__config

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
265265
// When this option is used, the token passed to `std::random_device`'s
266266
// constructor *must* be "/dev/urandom" -- anything else is an error.
267267
//
268-
// _LIBCPP_USING_NACL_RANDOM
269-
// NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
270-
// including accesses to the special files under `/dev`. This implementation
271-
// uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
272-
// When this option is used, the token passed to `std::random_device`'s
273-
// constructor *must* be "/dev/urandom" -- anything else is an error.
274-
//
275268
// _LIBCPP_USING_WIN32_RANDOM
276269
// Use rand_s(), for use on Windows.
277270
// When this option is used, the token passed to `std::random_device`'s
@@ -283,8 +276,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
283276
# define _LIBCPP_USING_GETENTROPY
284277
# elif defined(__Fuchsia__)
285278
# define _LIBCPP_USING_FUCHSIA_CPRNG
286-
# elif defined(__native_client__)
287-
# define _LIBCPP_USING_NACL_RANDOM
288279
# elif defined(_LIBCPP_WIN32API)
289280
# define _LIBCPP_USING_WIN32_RANDOM
290281
# else

libcxx/include/limits

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ protected:
219219
static _LIBCPP_CONSTEXPR const bool is_bounded = true;
220220
static _LIBCPP_CONSTEXPR const bool is_modulo = !std::is_signed<_Tp>::value;
221221

222-
# if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__)
222+
# if defined(__i386__) || defined(__x86_64__) || defined(__wasm__)
223223
static _LIBCPP_CONSTEXPR const bool traps = true;
224224
# else
225225
static _LIBCPP_CONSTEXPR const bool traps = false;

libcxx/src/random.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
# include <linux/random.h>
3232
# include <sys/ioctl.h>
3333
# endif
34-
#elif defined(_LIBCPP_USING_NACL_RANDOM)
35-
# include <nacl/nacl_random.h>
3634
#elif defined(_LIBCPP_USING_FUCHSIA_CPRNG)
3735
# include <zircon/syscalls.h>
3836
#endif
@@ -93,30 +91,6 @@ unsigned random_device::operator()() {
9391
return r;
9492
}
9593

96-
#elif defined(_LIBCPP_USING_NACL_RANDOM)
97-
98-
random_device::random_device(const string& __token) {
99-
if (__token != "/dev/urandom")
100-
std::__throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
101-
int error = nacl_secure_random_init();
102-
if (error)
103-
std::__throw_system_error(error, ("random device failed to open " + __token).c_str());
104-
}
105-
106-
random_device::~random_device() {}
107-
108-
unsigned random_device::operator()() {
109-
unsigned r;
110-
size_t n = sizeof(r);
111-
size_t bytes_written;
112-
int error = nacl_secure_random(&r, n, &bytes_written);
113-
if (error != 0)
114-
std::__throw_system_error(error, "random_device failed getting bytes");
115-
else if (bytes_written != n)
116-
std::__throw_runtime_error("random_device failed to obtain enough bytes");
117-
return r;
118-
}
119-
12094
#elif defined(_LIBCPP_USING_WIN32_RANDOM)
12195

12296
random_device::random_device(const string& __token) {

libcxx/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
#include "test_macros.h"
1616

17-
#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \
18-
defined(__wasm__)
17+
#if defined(__i386__) || defined(__x86_64__) || defined(__wasm__)
1918
static const bool integral_types_trap = true;
2019
#else
2120
static const bool integral_types_trap = false;

0 commit comments

Comments
 (0)