Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
compiler_hints.hpp
Go to the documentation of this file.
1#pragma once
2
3#ifdef _WIN32
4#define BB_INLINE __forceinline inline
5#else
6#define BB_INLINE __attribute__((always_inline)) inline
7#endif
8
9// TODO(AD): Other instrumentation?
10#ifdef XRAY
11#define BB_PROFILE [[clang::xray_always_instrument]] [[clang::noinline]]
12#define BB_NO_PROFILE [[clang::xray_never_instrument]]
13#else
14#define BB_PROFILE
15#define BB_NO_PROFILE
16#endif
17
18// Optimization hints for clang - which outcome of an expression is expected for better
19// branch-prediction optimization
20#ifdef __clang__
21#define BB_LIKELY(x) __builtin_expect(!!(x), 1)
22#define BB_UNLIKELY(x) __builtin_expect(!!(x), 0)
23#else
24#define BB_LIKELY(x) x
25#define BB_UNLIKELY(x) x
26#endif
27
28// Opinionated feature: functionally equivalent to [[maybe_unused]] but clearly
29// marks things DEFINITELY unused. Aims to be more readable, at the tradeoff of being a custom thingy.
30#define BB_UNUSED [[maybe_unused]]