clang 8.0.0

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