Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:51

0001 //===--- XRayInstr.h --------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 /// \file
0010 /// Defines the clang::XRayInstrKind enum.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CLANG_BASIC_XRAYINSTR_H
0015 #define LLVM_CLANG_BASIC_XRAYINSTR_H
0016 
0017 #include "clang/Basic/LLVM.h"
0018 #include "llvm/ADT/StringRef.h"
0019 #include "llvm/Support/MathExtras.h"
0020 #include <cassert>
0021 #include <cstdint>
0022 
0023 namespace clang {
0024 
0025 using XRayInstrMask = uint32_t;
0026 
0027 namespace XRayInstrKind {
0028 
0029 // TODO: Auto-generate these as we add more instrumentation kinds.
0030 enum XRayInstrOrdinal : XRayInstrMask {
0031   XRIO_FunctionEntry,
0032   XRIO_FunctionExit,
0033   XRIO_Custom,
0034   XRIO_Typed,
0035   XRIO_Count
0036 };
0037 
0038 constexpr XRayInstrMask None = 0;
0039 constexpr XRayInstrMask FunctionEntry = 1U << XRIO_FunctionEntry;
0040 constexpr XRayInstrMask FunctionExit = 1U << XRIO_FunctionExit;
0041 constexpr XRayInstrMask Custom = 1U << XRIO_Custom;
0042 constexpr XRayInstrMask Typed = 1U << XRIO_Typed;
0043 constexpr XRayInstrMask All = FunctionEntry | FunctionExit | Custom | Typed;
0044 
0045 } // namespace XRayInstrKind
0046 
0047 struct XRayInstrSet {
0048   bool has(XRayInstrMask K) const {
0049     assert(llvm::isPowerOf2_32(K));
0050     return Mask & K;
0051   }
0052 
0053   bool hasOneOf(XRayInstrMask K) const { return Mask & K; }
0054 
0055   void set(XRayInstrMask K, bool Value) {
0056     Mask = Value ? (Mask | K) : (Mask & ~K);
0057   }
0058 
0059   void clear(XRayInstrMask K = XRayInstrKind::All) { Mask &= ~K; }
0060 
0061   bool empty() const { return Mask == 0; }
0062 
0063   bool full() const { return Mask == XRayInstrKind::All; }
0064 
0065   XRayInstrMask Mask = 0;
0066 };
0067 
0068 /// Parses a command line argument into a mask.
0069 XRayInstrMask parseXRayInstrValue(StringRef Value);
0070 
0071 /// Serializes a set into a list of command line arguments.
0072 void serializeXRayInstrValue(XRayInstrSet Set,
0073                              SmallVectorImpl<StringRef> &Values);
0074 
0075 } // namespace clang
0076 
0077 #endif // LLVM_CLANG_BASIC_XRAYINSTR_H