clang 10.0.0git

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.
30 enum XRayInstrOrdinal : XRayInstrMask {
31 XRIO_Function,
32 XRIO_Custom,
33 XRIO_Typed,
34 XRIO_Count
35 };
36
37 constexpr XRayInstrMask None = 0;
38 constexpr XRayInstrMask Function = 1U << XRIO_Function;
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
67 XRayInstrMask parseXRayInstrValue(StringRef Value);
68
69 } // namespace clang
70
71 #endif // LLVM_CLANG_BASIC_XRAYINSTR_H
clang::XRayInstrSet::clear
void clear(XRayInstrMask K=XRayInstrKind::All)
Definition: XRayInstr.h:58
clang::XRayInstrKind::Typed
constexpr XRayInstrMask Typed
Definition: XRayInstr.h:40
clang::XRayInstrKind::Function
constexpr XRayInstrMask Function
Definition: XRayInstr.h:38
Value
Value
Definition: UninitializedValues.cpp:101
clang::XRayInstrKind::XRIO_Function
Definition: XRayInstr.h:31
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
clang::XRayInstrKind::XRayInstrOrdinal
XRayInstrOrdinal
Definition: XRayInstr.h:30
clang::XRayInstrKind::All
constexpr XRayInstrMask All
Definition: XRayInstr.h:41
clang::XRayInstrSet
Definition: XRayInstr.h:45
clang::XRayInstrKind::Custom
constexpr XRayInstrMask Custom
Definition: XRayInstr.h:39
clang::XRayInstrSet::hasOneOf
bool hasOneOf(XRayInstrMask K) const
Definition: XRayInstr.h:51
clang::XRayInstrKind::None
constexpr XRayInstrMask None
Definition: XRayInstr.h:37
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::XRayInstrSet::full
bool full() const
Definition: XRayInstr.h:62
clang::XRayInstrSet::has
bool has(XRayInstrMask K) const
Definition: XRayInstr.h:46
clang::XRayInstrMask
uint32_t XRayInstrMask
Definition: XRayInstr.h:25
clang::XRayInstrSet::empty
bool empty() const
Definition: XRayInstr.h:60
clang::XRayInstrKind::XRIO_Typed
Definition: XRayInstr.h:33
clang::parseXRayInstrValue
XRayInstrMask parseXRayInstrValue(StringRef Value)
Definition: XRayInstr.cpp:18
clang::XRayInstrKind::XRIO_Count
Definition: XRayInstr.h:34
clang::XRayInstrKind::XRIO_Custom
Definition: XRayInstr.h:32