1 //===--- XRayInstr.h --------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// Defines the clang::XRayInstrKind enum.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_BASIC_XRAYINSTR_H
16 #define LLVM_CLANG_BASIC_XRAYINSTR_H
18 #include "clang/Basic/LLVM.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/MathExtras.h"
26 using XRayInstrMask = uint32_t;
28 namespace XRayInstrKind {
30 // TODO: Auto-generate these as we add more instrumentation kinds.
31 enum XRayInstrOrdinal : XRayInstrMask {
38 constexpr XRayInstrMask None = 0;
39 constexpr XRayInstrMask Function = 1U << XRIO_Function;
40 constexpr XRayInstrMask Custom = 1U << XRIO_Custom;
41 constexpr XRayInstrMask Typed = 1U << XRIO_Typed;
42 constexpr XRayInstrMask All = Function | Custom | Typed;
44 } // namespace XRayInstrKind
47 bool has(XRayInstrMask K) const {
48 assert(llvm::isPowerOf2_32(K));
52 bool hasOneOf(XRayInstrMask K) const { return Mask & K; }
54 void set(XRayInstrMask K, bool Value) {
55 assert(llvm::isPowerOf2_32(K));
56 Mask = Value ? (Mask | K) : (Mask & ~K);
59 void clear(XRayInstrMask K = XRayInstrKind::All) { Mask &= ~K; }
61 bool empty() const { return Mask == 0; }
63 XRayInstrMask Mask = 0;
66 XRayInstrMask parseXRayInstrValue(StringRef Value);
70 #endif // LLVM_CLANG_BASIC_XRAYINSTR_H