1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

Revert "[NFC] Remove obsolete LLVM_GNUC_PREREQ"

The bots are sad, looks like GCC doesn't always have __has_builtin. I'll need to
modify the logic a bit.

llvm-svn: 367510
This commit is contained in:
JF Bastien 2019-08-01 03:40:59 +00:00
parent 90731e897e
commit f0cf151415
4 changed files with 61 additions and 81 deletions

View File

@ -75,7 +75,6 @@
#define LLVM_MSC_PREREQ(version) 0 #define LLVM_MSC_PREREQ(version) 0
#endif #endif
/// \macro LLVM_HAS_RVALUE_REFERENCE_THIS
/// Does the compiler support ref-qualifiers for *this? /// Does the compiler support ref-qualifiers for *this?
/// ///
/// Sadly, this is separate from just rvalue reference support because GCC /// Sadly, this is separate from just rvalue reference support because GCC
@ -86,7 +85,6 @@
#define LLVM_HAS_RVALUE_REFERENCE_THIS 0 #define LLVM_HAS_RVALUE_REFERENCE_THIS 0
#endif #endif
/// \macro LLVM_LVALUE_FUNCTION
/// Expands to '&' if ref-qualifiers for *this are supported. /// Expands to '&' if ref-qualifiers for *this are supported.
/// ///
/// This can be used to provide lvalue/rvalue overrides of member functions. /// This can be used to provide lvalue/rvalue overrides of member functions.
@ -97,35 +95,31 @@
#define LLVM_LVALUE_FUNCTION #define LLVM_LVALUE_FUNCTION
#endif #endif
/// \macro LLVM_LIBRARY_VISIBILITY /// LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked
/// If a class marked with this attribute is linked into a shared library, then /// into a shared library, then the class should be private to the library and
/// the class should be private to the library and not accessible from outside /// not accessible from outside it. Can also be used to mark variables and
/// it. Can also be used to mark variables and functions, making them private to /// functions, making them private to any shared library they are linked into.
/// any shared library they are linked into. On PE/COFF targets, library /// On PE/COFF targets, library visibility is the default, so this isn't needed.
/// visibility is the default, so this isn't needed. #if (__has_attribute(visibility) || LLVM_GNUC_PREREQ(4, 0, 0)) && \
#if __has_attribute(visibility) && \
!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32) !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32)
#define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden"))) #define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden")))
#else #else
#define LLVM_LIBRARY_VISIBILITY #define LLVM_LIBRARY_VISIBILITY
#endif #endif
/// \macro LLVM_PREFETCH
#if defined(__GNUC__) #if defined(__GNUC__)
#define LLVM_PREFETCH(addr, rw, locality) __builtin_prefetch(addr, rw, locality) #define LLVM_PREFETCH(addr, rw, locality) __builtin_prefetch(addr, rw, locality)
#else #else
#define LLVM_PREFETCH(addr, rw, locality) #define LLVM_PREFETCH(addr, rw, locality)
#endif #endif
/// \macro LLVM_ATTRIBUTE_USED #if __has_attribute(used) || LLVM_GNUC_PREREQ(3, 1, 0)
#if __has_attribute(used)
#define LLVM_ATTRIBUTE_USED __attribute__((__used__)) #define LLVM_ATTRIBUTE_USED __attribute__((__used__))
#else #else
#define LLVM_ATTRIBUTE_USED #define LLVM_ATTRIBUTE_USED
#endif #endif
/// \macro LLVM_NODISCARD /// LLVM_NODISCARD - Warn if a type or return value is discarded.
/// Warn if a type or return value is discarded.
#if __cplusplus > 201402L && __has_cpp_attribute(nodiscard) #if __cplusplus > 201402L && __has_cpp_attribute(nodiscard)
#define LLVM_NODISCARD [[nodiscard]] #define LLVM_NODISCARD [[nodiscard]]
#elif !__cplusplus #elif !__cplusplus
@ -138,47 +132,43 @@
#define LLVM_NODISCARD #define LLVM_NODISCARD
#endif #endif
/// \macro LLVM_ATTRIBUTE_REINITIALIZES // Indicate that a non-static, non-const C++ member function reinitializes
/// // the entire object to a known state, independent of the previous state of
/// Indicate that a non-static, non-const C++ member function reinitializes the // the object.
/// entire object to a known state, independent of the previous state of the //
/// object. // The clang-tidy check bugprone-use-after-move recognizes this attribute as a
/// // marker that a moved-from object has left the indeterminate state and can be
/// The clang-tidy check bugprone-use-after-move recognizes this attribute as a // reused.
/// marker that a moved-from object has left the indeterminate state and can be
/// reused.
#if __has_cpp_attribute(clang::reinitializes) #if __has_cpp_attribute(clang::reinitializes)
#define LLVM_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]] #define LLVM_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]]
#else #else
#define LLVM_ATTRIBUTE_REINITIALIZES #define LLVM_ATTRIBUTE_REINITIALIZES
#endif #endif
/// \macro LLVM_ATTRIBUTE_UNUSED // Some compilers warn about unused functions. When a function is sometimes
/// // used or not depending on build settings (e.g. a function only called from
/// Some compilers warn about unused functions. When a function is sometimes // within "assert"), this attribute can be used to suppress such warnings.
/// used or not depending on build settings (e.g. a function only called from //
/// within "assert"), this attribute can be used to suppress such warnings. // However, it shouldn't be used for unused *variables*, as those have a much
/// // more portable solution:
/// However, it shouldn't be used for unused *variables*, as those have a much // (void)unused_var_name;
/// more portable solution: // Prefer cast-to-void wherever it is sufficient.
/// (void)unused_var_name; #if __has_attribute(unused) || LLVM_GNUC_PREREQ(3, 1, 0)
/// Prefer cast-to-void wherever it is sufficient.
#if __has_attribute(unused)
#define LLVM_ATTRIBUTE_UNUSED __attribute__((__unused__)) #define LLVM_ATTRIBUTE_UNUSED __attribute__((__unused__))
#else #else
#define LLVM_ATTRIBUTE_UNUSED #define LLVM_ATTRIBUTE_UNUSED
#endif #endif
/// \macro LLVM_ATTRIBUTE_WEAK
// FIXME: Provide this for PE/COFF targets. // FIXME: Provide this for PE/COFF targets.
#if __has_attribute(weak) && \ #if (__has_attribute(weak) || LLVM_GNUC_PREREQ(4, 0, 0)) && \
(!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32)) (!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32))
#define LLVM_ATTRIBUTE_WEAK __attribute__((__weak__)) #define LLVM_ATTRIBUTE_WEAK __attribute__((__weak__))
#else #else
#define LLVM_ATTRIBUTE_WEAK #define LLVM_ATTRIBUTE_WEAK
#endif #endif
/// \macro LLVM_READNONE // Prior to clang 3.2, clang did not accept any spelling of
// __has_attribute(const), so assume it is supported.
#if defined(__clang__) || defined(__GNUC__) #if defined(__clang__) || defined(__GNUC__)
// aka 'CONST' but following LLVM Conventions. // aka 'CONST' but following LLVM Conventions.
#define LLVM_READNONE __attribute__((__const__)) #define LLVM_READNONE __attribute__((__const__))
@ -186,7 +176,6 @@
#define LLVM_READNONE #define LLVM_READNONE
#endif #endif
/// \macro LLVM_READONLY
#if __has_attribute(pure) || defined(__GNUC__) #if __has_attribute(pure) || defined(__GNUC__)
// aka 'PURE' but following LLVM Conventions. // aka 'PURE' but following LLVM Conventions.
#define LLVM_READONLY __attribute__((__pure__)) #define LLVM_READONLY __attribute__((__pure__))
@ -194,9 +183,7 @@
#define LLVM_READONLY #define LLVM_READONLY
#endif #endif
/// \macro LLVM_LIKELY #if __has_builtin(__builtin_expect) || LLVM_GNUC_PREREQ(4, 0, 0)
/// \macro LLVM_UNLIKELY
#if __has_builtin(__builtin_expect)
#define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true) #define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true)
#define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false) #define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false)
#else #else
@ -204,10 +191,9 @@
#define LLVM_UNLIKELY(EXPR) (EXPR) #define LLVM_UNLIKELY(EXPR) (EXPR)
#endif #endif
/// \macro LLVM_ATTRIBUTE_NOINLINE /// LLVM_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so,
/// On compilers where we have a directive to do so, mark a method "not for /// mark a method "not for inlining".
/// inlining". #if __has_attribute(noinline) || LLVM_GNUC_PREREQ(3, 4, 0)
#if __has_attribute(noinline)
#define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline)) #define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#define LLVM_ATTRIBUTE_NOINLINE __declspec(noinline) #define LLVM_ATTRIBUTE_NOINLINE __declspec(noinline)
@ -215,12 +201,11 @@
#define LLVM_ATTRIBUTE_NOINLINE #define LLVM_ATTRIBUTE_NOINLINE
#endif #endif
/// \macro LLVM_ATTRIBUTE_ALWAYS_INLINE /// LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do
/// On compilers where we have a directive to do so, mark a method "always /// so, mark a method "always inline" because it is performance sensitive. GCC
/// inline" because it is performance sensitive. GCC 3.4 supported this but is /// 3.4 supported this but is buggy in various cases and produces unimplemented
/// buggy in various cases and produces unimplemented errors, just use it in GCC /// errors, just use it in GCC 4.0 and later.
/// 4.0 and later. #if __has_attribute(always_inline) || LLVM_GNUC_PREREQ(4, 0, 0)
#if __has_attribute(always_inline)
#define LLVM_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) #define LLVM_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#define LLVM_ATTRIBUTE_ALWAYS_INLINE __forceinline #define LLVM_ATTRIBUTE_ALWAYS_INLINE __forceinline
@ -228,7 +213,6 @@
#define LLVM_ATTRIBUTE_ALWAYS_INLINE #define LLVM_ATTRIBUTE_ALWAYS_INLINE
#endif #endif
/// \macro LLVM_ATTRIBUTE_NORETURN
#ifdef __GNUC__ #ifdef __GNUC__
#define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn)) #define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
@ -237,7 +221,6 @@
#define LLVM_ATTRIBUTE_NORETURN #define LLVM_ATTRIBUTE_NORETURN
#endif #endif
/// \macro LLVM_ATTRIBUTE_RETURNS_NONNULL
#if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0) #if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0)
#define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) #define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
@ -246,9 +229,8 @@
#define LLVM_ATTRIBUTE_RETURNS_NONNULL #define LLVM_ATTRIBUTE_RETURNS_NONNULL
#endif #endif
/// \macro LLVM_ATTRIBUTE_RETURNS_NOALIAS /// \macro LLVM_ATTRIBUTE_RETURNS_NOALIAS Used to mark a function as returning a
/// Used to mark a function as returning a pointer that does not alias any other /// pointer that does not alias any other valid pointer.
/// valid pointer.
#ifdef __GNUC__ #ifdef __GNUC__
#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__)) #define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
@ -257,8 +239,7 @@
#define LLVM_ATTRIBUTE_RETURNS_NOALIAS #define LLVM_ATTRIBUTE_RETURNS_NOALIAS
#endif #endif
/// \macro LLVM_FALLTHROUGH /// LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
/// Mark fallthrough cases in switch statements.
#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
#define LLVM_FALLTHROUGH [[fallthrough]] #define LLVM_FALLTHROUGH [[fallthrough]]
#elif __has_cpp_attribute(gnu::fallthrough) #elif __has_cpp_attribute(gnu::fallthrough)
@ -273,8 +254,8 @@
#define LLVM_FALLTHROUGH #define LLVM_FALLTHROUGH
#endif #endif
/// \macro LLVM_REQUIRE_CONSTANT_INITIALIZATION /// LLVM_REQUIRE_CONSTANT_INITIALIZATION - Apply this to globals to ensure that
/// Apply this to globals to ensure that they are constant initialized. /// they are constant initialized.
#if __has_cpp_attribute(clang::require_constant_initialization) #if __has_cpp_attribute(clang::require_constant_initialization)
#define LLVM_REQUIRE_CONSTANT_INITIALIZATION \ #define LLVM_REQUIRE_CONSTANT_INITIALIZATION \
[[clang::require_constant_initialization]] [[clang::require_constant_initialization]]
@ -282,8 +263,8 @@
#define LLVM_REQUIRE_CONSTANT_INITIALIZATION #define LLVM_REQUIRE_CONSTANT_INITIALIZATION
#endif #endif
/// \macro LLVM_EXTENSION /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress
/// Support compilers where we have a keyword to suppress pedantic diagnostics. /// pedantic diagnostics.
#ifdef __GNUC__ #ifdef __GNUC__
#define LLVM_EXTENSION __extension__ #define LLVM_EXTENSION __extension__
#else #else
@ -305,18 +286,18 @@
decl decl
#endif #endif
/// On compilers which support it, expands to an expression which states that it /// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands
/// is undefined behavior for the compiler to reach this point. Otherwise is not /// to an expression which states that it is undefined behavior for the
/// defined. /// compiler to reach this point. Otherwise is not defined.
#if __has_builtin(__builtin_unreachable) #if __has_builtin(__builtin_unreachable) || LLVM_GNUC_PREREQ(4, 5, 0)
# define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable() # define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable()
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
# define LLVM_BUILTIN_UNREACHABLE __assume(false) # define LLVM_BUILTIN_UNREACHABLE __assume(false)
#endif #endif
/// On compilers which support it, expands to an expression which causes the /// LLVM_BUILTIN_TRAP - On compilers which support it, expands to an expression
/// program to exit abnormally. /// which causes the program to exit abnormally.
#if __has_builtin(__builtin_trap) #if __has_builtin(__builtin_trap) || LLVM_GNUC_PREREQ(4, 3, 0)
# define LLVM_BUILTIN_TRAP __builtin_trap() # define LLVM_BUILTIN_TRAP __builtin_trap()
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
// The __debugbreak intrinsic is supported by MSVC, does not require forward // The __debugbreak intrinsic is supported by MSVC, does not require forward
@ -328,9 +309,9 @@
# define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0 # define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0
#endif #endif
/// \macro LLVM_BUILTIN_DEBUGTRAP /// LLVM_BUILTIN_DEBUGTRAP - On compilers which support it, expands to
/// On compilers which support it, expands to an expression which causes the /// an expression which causes the program to break while running
/// program to break while running under a debugger. /// under a debugger.
#if __has_builtin(__builtin_debugtrap) #if __has_builtin(__builtin_debugtrap)
# define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap() # define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap()
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
@ -347,7 +328,7 @@
/// \macro LLVM_ASSUME_ALIGNED /// \macro LLVM_ASSUME_ALIGNED
/// Returns a pointer with an assumed alignment. /// Returns a pointer with an assumed alignment.
#if __has_builtin(__builtin_assume_aligned) #if __has_builtin(__builtin_assume_aligned) || LLVM_GNUC_PREREQ(4, 7, 0)
# define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a) # define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a)
#elif defined(LLVM_BUILTIN_UNREACHABLE) #elif defined(LLVM_BUILTIN_UNREACHABLE)
// As of today, clang does not support __builtin_assume_aligned. // As of today, clang does not support __builtin_assume_aligned.
@ -474,7 +455,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
#define LLVM_NO_SANITIZE(KIND) #define LLVM_NO_SANITIZE(KIND)
#endif #endif
/// \macro LLVM_DUMP_METHOD
/// Mark debug helper function definitions like dump() that should not be /// Mark debug helper function definitions like dump() that should not be
/// stripped from debug builds. /// stripped from debug builds.
/// Note that you should also surround dump() functions with /// Note that you should also surround dump() functions with

View File

@ -79,7 +79,7 @@ template <typename T> struct TrailingZerosCounter<T, 4> {
if (ZB != ZB_Undefined && Val == 0) if (ZB != ZB_Undefined && Val == 0)
return 32; return 32;
#if __has_builtin(__builtin_ctz) #if __has_builtin(__builtin_ctz) || LLVM_GNUC_PREREQ(4, 0, 0)
return __builtin_ctz(Val); return __builtin_ctz(Val);
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
unsigned long Index; unsigned long Index;
@ -95,7 +95,7 @@ template <typename T> struct TrailingZerosCounter<T, 8> {
if (ZB != ZB_Undefined && Val == 0) if (ZB != ZB_Undefined && Val == 0)
return 64; return 64;
#if __has_builtin(__builtin_ctzll) #if __has_builtin(__builtin_ctzll) || LLVM_GNUC_PREREQ(4, 0, 0)
return __builtin_ctzll(Val); return __builtin_ctzll(Val);
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
unsigned long Index; unsigned long Index;
@ -148,7 +148,7 @@ template <typename T> struct LeadingZerosCounter<T, 4> {
if (ZB != ZB_Undefined && Val == 0) if (ZB != ZB_Undefined && Val == 0)
return 32; return 32;
#if __has_builtin(__builtin_clz) #if __has_builtin(__builtin_clz) || LLVM_GNUC_PREREQ(4, 0, 0)
return __builtin_clz(Val); return __builtin_clz(Val);
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
unsigned long Index; unsigned long Index;
@ -164,7 +164,7 @@ template <typename T> struct LeadingZerosCounter<T, 8> {
if (ZB != ZB_Undefined && Val == 0) if (ZB != ZB_Undefined && Val == 0)
return 64; return 64;
#if __has_builtin(__builtin_clzll) #if __has_builtin(__builtin_clzll) || LLVM_GNUC_PREREQ(4, 0, 0)
return __builtin_clzll(Val); return __builtin_clzll(Val);
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
unsigned long Index; unsigned long Index;

View File

@ -42,7 +42,7 @@ inline uint16_t SwapByteOrder_16(uint16_t value) {
/// SwapByteOrder_32 - This function returns a byte-swapped representation of /// SwapByteOrder_32 - This function returns a byte-swapped representation of
/// the 32-bit argument. /// the 32-bit argument.
inline uint32_t SwapByteOrder_32(uint32_t value) { inline uint32_t SwapByteOrder_32(uint32_t value) {
#if defined(__llvm__) || !defined(__ICC) #if defined(__llvm__) || (LLVM_GNUC_PREREQ(4, 3, 0) && !defined(__ICC))
return __builtin_bswap32(value); return __builtin_bswap32(value);
#elif defined(_MSC_VER) && !defined(_DEBUG) #elif defined(_MSC_VER) && !defined(_DEBUG)
return _byteswap_ulong(value); return _byteswap_ulong(value);
@ -58,7 +58,7 @@ inline uint32_t SwapByteOrder_32(uint32_t value) {
/// SwapByteOrder_64 - This function returns a byte-swapped representation of /// SwapByteOrder_64 - This function returns a byte-swapped representation of
/// the 64-bit argument. /// the 64-bit argument.
inline uint64_t SwapByteOrder_64(uint64_t value) { inline uint64_t SwapByteOrder_64(uint64_t value) {
#if defined(__llvm__) || !defined(__ICC) #if defined(__llvm__) || (LLVM_GNUC_PREREQ(4, 3, 0) && !defined(__ICC))
return __builtin_bswap64(value); return __builtin_bswap64(value);
#elif defined(_MSC_VER) && !defined(_DEBUG) #elif defined(_MSC_VER) && !defined(_DEBUG)
return _byteswap_uint64(value); return _byteswap_uint64(value);

View File

@ -199,7 +199,7 @@ class is_trivially_copyable<T*> : public std::true_type {
// macro will be left undefined. // macro will be left undefined.
#if __cplusplus >= 201402L || defined(_MSC_VER) #if __cplusplus >= 201402L || defined(_MSC_VER)
#define LLVM_IS_FINAL(Ty) std::is_final<Ty>() #define LLVM_IS_FINAL(Ty) std::is_final<Ty>()
#elif __has_feature(is_final) #elif __has_feature(is_final) || LLVM_GNUC_PREREQ(4, 7, 0)
#define LLVM_IS_FINAL(Ty) __is_final(Ty) #define LLVM_IS_FINAL(Ty) __is_final(Ty)
#endif #endif