Skip to content

[libc++] Split the PSTL configuration macros into a separate header#205531

Merged
philnik777 merged 1 commit into
llvm:mainfrom
philnik777:split_pstl_config
Jun 26, 2026
Merged

[libc++] Split the PSTL configuration macros into a separate header#205531
philnik777 merged 1 commit into
llvm:mainfrom
philnik777:split_pstl_config

Conversation

@philnik777

Copy link
Copy Markdown
Contributor

This continues the effort to split <__config> into self-contained detail headers.

@philnik777
philnik777 requested a review from a team as a code owner June 24, 2026 11:35
@llvmorg-github-actions llvmorg-github-actions Bot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jun 24, 2026
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

This continues the effort to split &lt;__config&gt; into self-contained detail headers.


Full diff: https://github.com/llvm/llvm-project/pull/205531.diff

4 Files Affected:

  • (modified) libcxx/include/CMakeLists.txt (+1)
  • (modified) libcxx/include/__config (+1-47)
  • (added) libcxx/include/__configuration/pstl.h (+66)
  • (modified) libcxx/include/module.modulemap.in (+1)
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index cb7ae820bc012..6fd73338bc7b2 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -343,6 +343,7 @@ set(files
   __configuration/language.h
   __configuration/namespace.h
   __configuration/platform.h
+  __configuration/pstl.h
   __configuration/utility.h
   __coroutine/coroutine_handle.h
   __coroutine/coroutine_traits.h
diff --git a/libcxx/include/__config b/libcxx/include/__config
index fdd0558fbec6f..4bf305e688f54 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -28,6 +28,7 @@
 #  include <__configuration/language.h>
 #  include <__configuration/namespace.h>
 #  include <__configuration/platform.h>
+#  include <__configuration/pstl.h>
 
 // The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html
 
@@ -446,53 +447,6 @@ typedef __char32_t char32_t;
 #    define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
 #  endif
 
-#  define _PSTL_PRAGMA(x) _Pragma(#x)
-
-// Enable SIMD for compilers that support OpenMP 4.0
-#  if (defined(_OPENMP) && _OPENMP >= 201307)
-
-#    define _PSTL_UDR_PRESENT
-#    define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
-#    define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
-#    define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
-#    define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
-#    define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
-#    define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
-
-// Declaration of reduction functor, where
-// NAME - the name of the functor
-// OP - type of the callable object with the reduction operation
-// omp_in - refers to the local partial result
-// omp_out - refers to the final value of the combiner operator
-// omp_priv - refers to the private copy of the initial value
-// omp_orig - refers to the original variable to be reduced
-#    define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)                                                                   \
-      _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
-
-#  elif defined(_LIBCPP_COMPILER_CLANG_BASED)
-
-#    define _PSTL_PRAGMA_SIMD _Pragma("clang loop vectorize(enable) interleave(enable)")
-#    define _PSTL_PRAGMA_DECLARE_SIMD
-#    define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
-#    define _PSTL_PRAGMA_SIMD_SCAN(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
-#    define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
-#    define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
-#    define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
-
-#  else // (defined(_OPENMP) && _OPENMP >= 201307)
-
-#    define _PSTL_PRAGMA_SIMD
-#    define _PSTL_PRAGMA_DECLARE_SIMD
-#    define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
-#    define _PSTL_PRAGMA_SIMD_SCAN(PRM)
-#    define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
-#    define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
-#    define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
-
-#  endif // (defined(_OPENMP) && _OPENMP >= 201307)
-
-#  define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
-
 #endif // __cplusplus
 
 #endif // _LIBCPP___CONFIG
diff --git a/libcxx/include/__configuration/pstl.h b/libcxx/include/__configuration/pstl.h
new file mode 100644
index 0000000000000..f7a6598566acd
--- /dev/null
+++ b/libcxx/include/__configuration/pstl.h
@@ -0,0 +1,66 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___CONFIGURATION_PSTL_H
+#define _LIBCPP___CONFIGURATION_PSTL_H
+
+#include <__config_site>
+
+#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+#  pragma GCC system_header
+#endif
+
+#define _PSTL_PRAGMA(x) _Pragma(#x)
+
+// Enable SIMD for compilers that support OpenMP 4.0
+#if (defined(_OPENMP) && _OPENMP >= 201307)
+
+#  define _PSTL_UDR_PRESENT
+#  define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
+#  define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
+#  define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
+#  define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
+#  define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
+#  define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
+
+// Declaration of reduction functor, where
+// NAME - the name of the functor
+// OP - type of the callable object with the reduction operation
+// omp_in - refers to the local partial result
+// omp_out - refers to the final value of the combiner operator
+// omp_priv - refers to the private copy of the initial value
+// omp_orig - refers to the original variable to be reduced
+#  define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)                                                                     \
+    _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
+
+#elif defined(_LIBCPP_COMPILER_CLANG_BASED)
+
+#  define _PSTL_PRAGMA_SIMD _Pragma("clang loop vectorize(enable) interleave(enable)")
+#  define _PSTL_PRAGMA_DECLARE_SIMD
+#  define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
+#  define _PSTL_PRAGMA_SIMD_SCAN(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
+#  define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
+#  define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
+#  define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
+
+#else // (defined(_OPENMP) && _OPENMP >= 201307)
+
+#  define _PSTL_PRAGMA_SIMD
+#  define _PSTL_PRAGMA_DECLARE_SIMD
+#  define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
+#  define _PSTL_PRAGMA_SIMD_SCAN(PRM)
+#  define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
+#  define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
+#  define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
+
+#endif // (defined(_OPENMP) && _OPENMP >= 201307)
+
+#define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
+
+#endif // _LIBCPP___CONFIGURATION_PSTL_H
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index b11055940a82c..52fd544ce7329 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -13,6 +13,7 @@ module std_config [system] {
   textual header "__configuration/language.h"
   textual header "__configuration/namespace.h"
   textual header "__configuration/platform.h"
+  textual header "__configuration/pstl.h"
   textual header "__configuration/utility.h"
   textual header "version"
 }

@ldionne ldionne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I think there's some dead code in the frozen 03 headers that can be removed

@philnik777
philnik777 enabled auto-merge (squash) June 26, 2026 16:30
@philnik777
philnik777 disabled auto-merge June 26, 2026 16:30
@philnik777
philnik777 merged commit 78af5e2 into llvm:main Jun 26, 2026
75 of 80 checks passed
@philnik777
philnik777 deleted the split_pstl_config branch June 26, 2026 18:36
LouisLu060211 pushed a commit to LouisLu060211/llvm-project that referenced this pull request Jun 30, 2026
…lvm#205531)

This continues the effort to split `<__config>` into self-contained
detail headers.
maarcosrmz pushed a commit to maarcosrmz/llvm-project that referenced this pull request Jul 1, 2026
…lvm#205531)

This continues the effort to split `<__config>` into self-contained
detail headers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants