Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 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_FunctionEntry,
32
  XRIO_FunctionExit,
33
  XRIO_Custom,
34
  XRIO_Typed,
35
  XRIO_Count
36
};
37
 
38
constexpr XRayInstrMask None = 0;
39
constexpr XRayInstrMask FunctionEntry = 1U << XRIO_FunctionEntry;
40
constexpr XRayInstrMask FunctionExit = 1U << XRIO_FunctionExit;
41
constexpr XRayInstrMask Custom = 1U << XRIO_Custom;
42
constexpr XRayInstrMask Typed = 1U << XRIO_Typed;
43
constexpr XRayInstrMask All = FunctionEntry | FunctionExit | Custom | 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
 
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
/// Parses a command line argument into a mask.
69
XRayInstrMask parseXRayInstrValue(StringRef Value);
70
 
71
/// Serializes a set into a list of command line arguments.
72
void serializeXRayInstrValue(XRayInstrSet Set,
73
                             SmallVectorImpl<StringRef> &Values);
74
 
75
} // namespace clang
76
 
77
#endif // LLVM_CLANG_BASIC_XRAYINSTR_H