2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * @author Matthias Braun, Sebastian Hack
24 * @brief Macros to instruct the compiler compiling libFirm.
27 #ifndef FIRM_COMPILER_H
28 #define FIRM_COMPILER_H
31 * Asserts that the constant expression x is not zero at compiletime. name has
32 * to be a unique identifier.
34 * @note This uses the fact, that double case labels are not allowed.
36 #define COMPILETIME_ASSERT(x, name) \
37 static __attribute__((unused)) void compiletime_assert_##name (int h) { \
38 switch(h) { case 0: case (x): ; } \
43 * Indicates to the compiler that the value of x is very likely 1
44 * @note Only use this in speed critical code and when you are sure x is often 1
46 #define LIKELY(x) __builtin_expect((x), 1)
49 * Indicates to the compiler that it's very likely that x is 0
50 * @note Only use this in speed critical code and when you are sure x is often 0
52 #define UNLIKELY(x) __builtin_expect((x), 0)
55 * Tell the compiler, that a function is pure, i.e. it only
56 * uses its parameters and never modifies the "state".
57 * Add this macro after the return type.
59 #define PURE __attribute__((const))