Loading...
Searching...
No Matches
Go to the documentation of this file.
41#ifndef __BASE_COMPILER_HH__
42#define __BASE_COMPILER_HH__
46#include "config/have_deprecated_namespace.hh"
59# define GEM5_PACKED [[gnu::packed]]
62# define GEM5_NO_INLINE [[gnu::noinline]]
65# define GEM5_PUBLIC [[gnu:visibility("default")]]
66# define GEM5_LOCAL [[gnu::visibility("hidden")]]
67# define GEM5_WEAK [[gnu::weak]]
70# define GEM5_ALIGNED(alignment) [[gnu::aligned(alignment)]]
73# define GEM5_UNREACHABLE __builtin_unreachable()
80# define GEM5_LIKELY(cond) __builtin_expect(!!(cond), 1)
81# define GEM5_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
88# define GEM5_DEPRECATED_MACRO(name, definition, message) \
89 ([](){[[deprecated(message)]] int name{}; return name;}(), (definition))
92# define GEM5_DEPRECATED_MACRO_STMT(name, definition, message) \
93 do {{definition;} GEM5_DEPRECATED_MACRO(name, ({}), message);} while (0)
98# define GEM5_DEPRECATED_CLASS(old_class, new_class) \
100 [[deprecated("Please use the new class name: '" #new_class "'")]] = \
108# if HAVE_DEPRECATED_NAMESPACE
109# define GEM5_DEPRECATED_NAMESPACE(old_namespace, new_namespace) \
110 namespace new_namespace {} \
111 namespace [[deprecated("Please use the new namespace: '" \
112 #new_namespace "'")]] old_namespace { \
113 using namespace new_namespace; \
116# define GEM5_DEPRECATED_NAMESPACE(old_namespace, new_namespace) \
117 namespace new_namespace {} \
118 namespace old_namespace = new_namespace
127#define GEM5_FOR_EACH_IN_PACK(...) \
128do { [[maybe_unused]] int i[] = { 0, ((void)(__VA_ARGS__), 0)... }; } while (0)
131# error "Don't know what to do for your compiler."
138#if defined(__clang__)
139# define GEM5_CLASS_VAR_USED GEM5_VAR_USED
141# define GEM5_CLASS_VAR_USED
145#define M5_VAR_USED GEM5_VAR_USED
146#define M5_NODISCARD GEM5_NO_DISCARD
147#define M5_FALLTHROUGH GEM5_FALLTHROUGH
148#define M5_ATTR_PACKED GEM5_PACKED
149#define M5_NO_INLINE GEM5_NO_INLINE
150#define M5_PUBLIC GEM5_PUBLIC
151#define M5_LOCAL GEM5_LOCAL
152#define M5_WEAK GEM5_WEAK
153#define M5_ALIGNED(x) GEM5_ALIGNED(x)
154#define M5_UNREACHABLE GEM5_UNREACHABLE
155#define M5_LIKELY(x) GEM5_LIKELY(x)
156#define M5_UNLIKELY(x) GEM5_UNLIKELY(x)
157#define M5_FOR_EACH_IN_PACK(...) GEM5_FOR_EACH_IN_PACK(__VA_ARGS__)
158#define M5_CLASS_VAR_USED GEM5_CLASS_VAR_USED
161#define GEM5_FALLTHROUGH GEM5_DEPRECATED_MACRO_STMT(GEM5_FALLTHROUGH,,\
162 "Please use the [[fallthrough]] attribute directly."); [[fallthrough]]
163#define GEM5_DEPRECATED(message) \
164 [[deprecated(message " The GEM5_DEPRECATED macro is also deprecated, "\
165 "please use the [[deprecated()]] attribute directly.")]]
166#define GEM5_DEPRECATED_ENUM_VAL(message) \
167 [[deprecated(message " The GEM5_DEPRECATED_ENUM_VAL macro is also "\
168 "deprecated, please use the [[deprecated()]] attribute "\
173#define GEM5_NO_DISCARD [[nodiscard]]
174#define GEM5_VAR_USED [[maybe_unused]]
Generated on Tue Jun 18 2024 16:24:00 for gem5 by doxygen 1.11.0