Remove LLVM_GLOBAL_VISIBILITY, which is unused, and was not working properly.
[oota-llvm.git] / include / llvm / Support / Compiler.h
1 //===-- llvm/Support/Compiler.h - Compiler abstraction support --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines several macros, based on the current compiler.  This allows
11 // use of compiler-specific features in a way that remains portable.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_SUPPORT_COMPILER_H
16 #define LLVM_SUPPORT_COMPILER_H
17
18 /// LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked
19 /// into a shared library, then the class should be private to the library and
20 /// not accessible from outside it.  Can also be used to mark variables and
21 /// functions, making them private to any shared library they are linked into.
22 #if (__GNUC__ >= 4) && !defined(__MINGW32__) && !defined(__CYGWIN__)
23 #define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden")))
24 #else
25 #define LLVM_LIBRARY_VISIBILITY
26 #endif
27
28 #if (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
29 #define ATTRIBUTE_USED __attribute__((__used__))
30 #else
31 #define ATTRIBUTE_USED
32 #endif
33
34 #if (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
35 #define ATTRIBUTE_UNUSED __attribute__((__unused__))
36 #else
37 #define ATTRIBUTE_UNUSED
38 #endif
39
40 #ifdef __GNUC__ // aka 'ATTRIBUTE_CONST' but following LLVM Conventions.
41 #define ATTRIBUTE_READNONE __attribute__((__const__))
42 #else
43 #define ATTRIBUTE_READNONE
44 #endif
45
46 #ifdef __GNUC__  // aka 'ATTRIBUTE_PURE' but following LLVM Conventions.
47 #define ATTRIBUTE_READONLY __attribute__((__pure__))
48 #else
49 #define ATTRIBUTE_READONLY
50 #endif
51
52 #if (__GNUC__ >= 4)
53 #define BUILTIN_EXPECT(EXPR, VALUE) __builtin_expect((EXPR), (VALUE))
54 #else
55 #define BUILTIN_EXPECT(EXPR, VALUE) (EXPR)
56 #endif
57
58 // C++ doesn't support 'extern template' of template specializations.  GCC does,
59 // but requires __extension__ before it.  In the header, use this:
60 //   EXTERN_TEMPLATE_INSTANTIATION(class foo<bar>);
61 // in the .cpp file, use this:
62 //   TEMPLATE_INSTANTIATION(class foo<bar>);
63 #ifdef __GNUC__
64 #define EXTERN_TEMPLATE_INSTANTIATION(X) __extension__ extern template X
65 #define TEMPLATE_INSTANTIATION(X) template X
66 #else
67 #define EXTERN_TEMPLATE_INSTANTIATION(X)
68 #define TEMPLATE_INSTANTIATION(X)
69 #endif
70
71 // DISABLE_INLINE - On compilers where we have a directive to do so, mark a
72 // method "not for inlining".
73 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
74 #define DISABLE_INLINE __attribute__((noinline))
75 #elif defined(_MSC_VER)
76 #define DISABLE_INLINE __declspec(noinline)
77 #else
78 #define DISABLE_INLINE
79 #endif
80
81 // ALWAYS_INLINE - On compilers where we have a directive to do so, mark a
82 // method "always inline" because it is performance sensitive.
83 // GCC 3.4 supported this but is buggy in various cases and produces
84 // unimplemented errors, just use it in GCC 4.0 and later.
85 #if __GNUC__ > 3
86 #define ALWAYS_INLINE __attribute__((always_inline))
87 #else
88 // TODO: No idea how to do this with MSVC.
89 #define ALWAYS_INLINE
90 #endif
91
92
93 #ifdef __GNUC__
94 #define NORETURN __attribute__((noreturn))
95 #elif defined(_MSC_VER)
96 #define NORETURN __declspec(noreturn)
97 #else
98 #define NORETURN
99 #endif
100
101 #endif