clang  9.0.0svn
XRayInstr.h
Go to the documentation of this file.
1 //===--- XRayInstr.h --------------------------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// Defines the clang::XRayInstrKind enum.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_BASIC_XRAYINSTR_H
15 #define LLVM_CLANG_BASIC_XRAYINSTR_H
16 
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/MathExtras.h"
20 #include <cassert>
21 #include <cstdint>
22 
23 namespace clang {
24 
25 using XRayInstrMask = uint32_t;
26 
27 namespace XRayInstrKind {
28 
29 // TODO: Auto-generate these as we add more instrumentation kinds.
35 };
36 
37 constexpr XRayInstrMask None = 0;
39 constexpr XRayInstrMask Custom = 1U << XRIO_Custom;
40 constexpr XRayInstrMask Typed = 1U << XRIO_Typed;
41 constexpr XRayInstrMask All = Function | Custom | Typed;
42 
43 } // namespace XRayInstrKind
44 
45 struct XRayInstrSet {
46  bool has(XRayInstrMask K) const {
47  assert(llvm::isPowerOf2_32(K));
48  return Mask & K;
49  }
50 
51  bool hasOneOf(XRayInstrMask K) const { return Mask & K; }
52 
53  void set(XRayInstrMask K, bool Value) {
54  assert(llvm::isPowerOf2_32(K));
55  Mask = Value ? (Mask | K) : (Mask & ~K);
56  }
57 
58  void clear(XRayInstrMask K = XRayInstrKind::All) { Mask &= ~K; }
59 
60  bool empty() const { return Mask == 0; }
61 
62  bool full() const { return Mask == XRayInstrKind::All; }
63 
64  XRayInstrMask Mask = 0;
65 };
66 
68 
69 } // namespace clang
70 
71 #endif // LLVM_CLANG_BASIC_XRAYINSTR_H
void clear(XRayInstrMask K=XRayInstrKind::All)
Definition: XRayInstr.h:58
constexpr XRayInstrMask Typed
Definition: XRayInstr.h:40
constexpr XRayInstrMask Function
Definition: XRayInstr.h:38
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
constexpr XRayInstrMask All
Definition: XRayInstr.h:41
constexpr XRayInstrMask Custom
Definition: XRayInstr.h:39
bool hasOneOf(XRayInstrMask K) const
Definition: XRayInstr.h:51
constexpr XRayInstrMask None
Definition: XRayInstr.h:37
Dataflow Directional Tag Classes.
bool full() const
Definition: XRayInstr.h:62
bool has(XRayInstrMask K) const
Definition: XRayInstr.h:46
uint32_t XRayInstrMask
Definition: XRayInstr.h:25
bool empty() const
Definition: XRayInstr.h:60
XRayInstrMask parseXRayInstrValue(StringRef Value)
Definition: XRayInstr.cpp:18