brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · b9f40b6 Raw
56 lines · c
1//===-- Common constants and defines for arm --------------------*- C++ -*-===//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_ARM_COMMON_H10#define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_ARM_COMMON_H11 12#include "src/__support/macros/attributes.h" // LIBC_INLINE_VAR13#include "src/string/memory_utils/utils.h"   // CPtr, Ptr, distance_to_align14 15#include <stddef.h> // size_t16 17// Our minimum supported compiler version does not recognize the standard18// [[likely]] / [[unlikely]] attributes so we use the preprocessor.19 20// https://libc.llvm.org/compiler_support.html21// Support for [[likely]] / [[unlikely]]22//  [X] GCC 12.223//  [X] Clang 1224//  [ ] Clang 1125#define LIBC_ATTR_LIKELY [[likely]]26#define LIBC_ATTR_UNLIKELY [[unlikely]]27 28#if defined(LIBC_COMPILER_IS_CLANG)29#if LIBC_COMPILER_CLANG_VER < 120030#undef LIBC_ATTR_LIKELY31#undef LIBC_ATTR_UNLIKELY32#define LIBC_ATTR_LIKELY33#define LIBC_ATTR_UNLIKELY34#endif35#endif36 37namespace LIBC_NAMESPACE_DECL {38 39LIBC_INLINE_VAR constexpr size_t kWordSize = sizeof(uint32_t);40 41enum class AssumeAccess { kUnknown, kAligned };42enum class BlockOp { kFull, kByWord };43 44LIBC_INLINE auto misaligned(CPtr ptr) {45  return distance_to_align_down<kWordSize>(ptr);46}47 48LIBC_INLINE CPtr bitwise_or(CPtr a, CPtr b) {49  return cpp::bit_cast<CPtr>(cpp::bit_cast<uintptr_t>(a) |50                             cpp::bit_cast<uintptr_t>(b));51}52 53} // namespace LIBC_NAMESPACE_DECL54 55#endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_ARM_COMMON_H56