[Openmp-commits] [llvm] [openmp] [Offload] Clean up and split Shared/Utils.h (PR #194876)
Kevin Sala Penades via Openmp-commits
openmp-commits at lists.llvm.org
Wed Apr 29 09:15:28 PDT 2026
================
@@ -63,6 +62,22 @@ template <typename To, typename From> inline To bitCast(From V) {
return __builtin_bit_cast(To, V);
}
+/// Return the first bit set in \p V.
+template <typename T> inline int ctz(T V) { return __builtin_ctzg(V); }
+
+/// Return the number of bits set in \p V.
+template <typename T> inline int popc(T V) { return __builtin_popcountg(V); }
+
+/// Return \p V aligned up to the nearest power of two multiple of \p A.
+template <typename T, typename U> inline int alignUp(T V, U A) {
+ return __builtin_align_up(V, A);
+}
+
+/// Return \p Ptr advanced by \p Offset bytes.
+template <typename T, typename U> T *advancePtr(T *Ptr, U Offset) {
+ return reinterpret_cast<T *>(reinterpret_cast<char *>(Ptr) + Offset);
----------------
kevinsala wrote:
Does this work for const pointers?
https://github.com/llvm/llvm-project/pull/194876
More information about the Openmp-commits
mailing list