Mark function used by asm block as used, otherwise optimizer may not see the use...
[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 // The VISIBILITY_HIDDEN macro, used for marking classes with the GCC-specific
19 // visibility("hidden") attribute.
20 #if (__GNUC__ >= 4) && !defined(__MINGW32__)
21 #define VISIBILITY_HIDDEN __attribute__ ((visibility("hidden")))
22 #else
23 #define VISIBILITY_HIDDEN
24 #endif
25
26 #if (__GNUC__ >= 4)
27 #define ATTRIBUTE_USED __attribute__((__used__))
28 #else
29 #define ATTRIBUTE_USED
30 #endif
31
32 // C++ doesn't support 'extern template' of template specializations.  GCC does,
33 // but requires __extension__ before it.  In the header, use this:
34 //   EXTERN_TEMPLATE_INSTANTIATION(class foo<bar>);
35 // in the .cpp file, use this:
36 //   TEMPLATE_INSTANTIATION(class foo<bar>);
37 #ifdef __GNUC__
38 #define EXTERN_TEMPLATE_INSTANTIATION(X) __extension__ extern template X
39 #define TEMPLATE_INSTANTIATION(X) template X
40 #else
41 #define EXTERN_TEMPLATE_INSTANTIATION(X)
42 #define TEMPLATE_INSTANTIATION(X)
43 #endif
44
45 // DISABLE_INLINE - On compilers where we have a directive to do so, mark a
46 // method "not for inlining".
47 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
48 #define DISABLE_INLINE __attribute__((noinline))
49 #else
50 #define DISABLE_INLINE
51 #endif
52
53 #endif