1 //===--- XRayInstr.h --------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// Defines the clang::XRayInstrKind enum.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_BASIC_XRAYINSTR_H
15 #define LLVM_CLANG_BASIC_XRAYINSTR_H
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/MathExtras.h"
25 using XRayInstrMask = uint32_t;
27 namespace XRayInstrKind {
29 // TODO: Auto-generate these as we add more instrumentation kinds.
30 enum XRayInstrOrdinal : XRayInstrMask {
38 constexpr XRayInstrMask None = 0;
39 constexpr XRayInstrMask FunctionEntry = 1U << XRIO_FunctionEntry;
40 constexpr XRayInstrMask FunctionExit = 1U << XRIO_FunctionExit;
41 constexpr XRayInstrMask Custom = 1U << XRIO_Custom;
42 constexpr XRayInstrMask Typed = 1U << XRIO_Typed;
43 constexpr XRayInstrMask All = FunctionEntry | FunctionExit | Custom | Typed;
45 } // namespace XRayInstrKind
48 bool has(XRayInstrMask K) const {
49 assert(llvm::isPowerOf2_32(K));
53 bool hasOneOf(XRayInstrMask K) const { return Mask & K; }
55 void set(XRayInstrMask K, bool Value) {
56 Mask = Value ? (Mask | K) : (Mask & ~K);
59 void clear(XRayInstrMask K = XRayInstrKind::All) { Mask &= ~K; }
61 bool empty() const { return Mask == 0; }
63 bool full() const { return Mask == XRayInstrKind::All; }
65 XRayInstrMask Mask = 0;
68 XRayInstrMask parseXRayInstrValue(StringRef Value);
72 #endif // LLVM_CLANG_BASIC_XRAYINSTR_H