clang  14.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.
36 };
37 
38 constexpr XRayInstrMask None = 0;
42 constexpr XRayInstrMask Typed = 1U << XRIO_Typed;
44 
45 } // namespace XRayInstrKind
46 
47 struct XRayInstrSet {
48  bool has(XRayInstrMask K) const {
49  assert(llvm::isPowerOf2_32(K));
50  return Mask & K;
51  }
52 
53  bool hasOneOf(XRayInstrMask K) const { return Mask & K; }
54 
55  void set(XRayInstrMask K, bool Value) {
56  Mask = Value ? (Mask | K) : (Mask & ~K);
57  }
58 
60 
61  bool empty() const { return Mask == 0; }
62 
63  bool full() const { return Mask == XRayInstrKind::All; }
64 
66 };
67 
68 /// Parses a command line argument into a mask.
70 
71 /// Serializes a set into a list of command line arguments.
74 
75 } // namespace clang
76 
77 #endif // LLVM_CLANG_BASIC_XRAYINSTR_H
clang::XRayInstrKind::XRIO_Typed
@ XRIO_Typed
Definition: XRayInstr.h:34
clang::XRayInstrKind::XRIO_Count
@ XRIO_Count
Definition: XRayInstr.h:35
clang::XRayInstrSet::set
void set(XRayInstrMask K, bool Value)
Definition: XRayInstr.h:55
clang::XRayInstrKind::FunctionEntry
constexpr XRayInstrMask FunctionEntry
Definition: XRayInstr.h:39
clang::XRayInstrSet::Mask
XRayInstrMask Mask
Definition: XRayInstr.h:65
clang::XRayInstrSet
Definition: XRayInstr.h:47
clang::XRayInstrKind::XRIO_Custom
@ XRIO_Custom
Definition: XRayInstr.h:33
U
clang::XRayInstrKind::All
constexpr XRayInstrMask All
Definition: XRayInstr.h:43
clang::XRayInstrKind::None
constexpr XRayInstrMask None
Definition: XRayInstr.h:38
clang::XRayInstrKind::XRIO_FunctionExit
@ XRIO_FunctionExit
Definition: XRayInstr.h:32
clang::XRayInstrKind::XRIO_FunctionEntry
@ XRIO_FunctionEntry
Definition: XRayInstr.h:31
clang::XRayInstrSet::empty
bool empty() const
Definition: XRayInstr.h:61
clang::parseXRayInstrValue
XRayInstrMask parseXRayInstrValue(StringRef Value)
Parses a command line argument into a mask.
Definition: XRayInstr.cpp:19
clang::XRayInstrKind::FunctionExit
constexpr XRayInstrMask FunctionExit
Definition: XRayInstr.h:40
Value
Value
Definition: UninitializedValues.cpp:102
clang::XRayInstrSet::clear
void clear(XRayInstrMask K=XRayInstrKind::All)
Definition: XRayInstr.h:59
LLVM.h
clang::XRayInstrKind::XRayInstrOrdinal
XRayInstrOrdinal
Definition: XRayInstr.h:30
clang::XRayInstrMask
uint32_t XRayInstrMask
Definition: XRayInstr.h:25
clang::XRayInstrSet::full
bool full() const
Definition: XRayInstr.h:63
clang::serializeXRayInstrValue
void serializeXRayInstrValue(XRayInstrSet Set, SmallVectorImpl< StringRef > &Values)
Serializes a set into a list of command line arguments.
Definition: XRayInstr.cpp:34
clang
Definition: CalledOnceCheck.h:17
clang::XRayInstrSet::hasOneOf
bool hasOneOf(XRayInstrMask K) const
Definition: XRayInstr.h:53
clang::XRayInstrSet::has
bool has(XRayInstrMask K) const
Definition: XRayInstr.h:48
clang::XRayInstrKind::Custom
constexpr XRayInstrMask Custom
Definition: XRayInstr.h:41
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::XRayInstrKind::Typed
constexpr XRayInstrMask Typed
Definition: XRayInstr.h:42