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
5
#else
6
#define BB_INLINE __attribute__((always_inline)) inline
7
#endif
8
9
// Statement-position force-inline hint, applied to a call statement (not a function). The underlying
10
// `[[clang::always_inline]]` statement attribute is a Clang 12+ extension; GCC rejects an attribute at
11
// the start of a statement ("attributes at the beginning of statement are ignored", an error under
12
// -Werror=attributes). Expand to nothing off Clang -- GCC inlines these call sites at -O3 regardless;
13
// the hint matters on the Clang/WASM -Oz path. See vectorized_for.hpp for the rationale.
14
#ifdef __clang__
15
#define BB_INLINE_STMT [[clang::always_inline]]
16
#else
17
#define BB_INLINE_STMT
18
#endif
19
20
// TODO(AD): Other instrumentation?
21
#ifdef XRAY
22
#define BB_PROFILE [[clang::xray_always_instrument]] [[clang::noinline]]
23
#define BB_NO_PROFILE [[clang::xray_never_instrument]]
24
#else
25
#define BB_PROFILE
26
#define BB_NO_PROFILE
27
#endif
28
29
// Optimization hints for clang - which outcome of an expression is expected for better
30
// branch-prediction optimization
31
#ifdef __clang__
32
#define BB_LIKELY(x) __builtin_expect(!!(x), 1)
33
#define BB_UNLIKELY(x) __builtin_expect(!!(x), 0)
34
#else
35
#define BB_LIKELY(x) x
36
#define BB_UNLIKELY(x) x
37
#endif
38
39
// Opinionated feature: functionally equivalent to [[maybe_unused]] but clearly
40
// marks things DEFINITELY unused. Aims to be more readable, at the tradeoff of being a custom thingy.
41
#define BB_UNUSED [[maybe_unused]]
src
barretenberg
common
compiler_hints.hpp
Generated by
1.9.8