LLVM  10.0.0svn
Symbol.h
Go to the documentation of this file.
1 //===- llvm/TextAPI/Symbol.h - TAPI Symbol ----------------------*- 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 #ifndef LLVM_TEXTAPI_MACHO_SYMBOL_H
10 #define LLVM_TEXTAPI_MACHO_SYMBOL_H
11 
12 #include "llvm/ADT/BitmaskEnum.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/Error.h"
17 
18 namespace llvm {
19 namespace MachO {
20 
21 // clang-format off
22 
23 /// Symbol flags.
24 enum class SymbolFlags : uint8_t {
25  /// No flags
26  None = 0,
27 
28  /// Thread-local value symbol
29  ThreadLocalValue = 1U << 0,
30 
31  /// Weak defined symbol
32  WeakDefined = 1U << 1,
33 
34  /// Weak referenced symbol
35  WeakReferenced = 1U << 2,
36 
37  /// Undefined
38  Undefined = 1U << 3,
39 
40  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Undefined),
41 };
42 
43 // clang-format on
44 
45 enum class SymbolKind : uint8_t {
50 };
51 
52 class Symbol {
53 public:
55  ArchitectureSet Architectures, SymbolFlags Flags)
56  : Name(Name), Architectures(Architectures), Kind(Kind), Flags(Flags) {}
57 
58  SymbolKind getKind() const { return Kind; }
59  StringRef getName() const { return Name; }
60  ArchitectureSet getArchitectures() const { return Architectures; }
61  void addArchitectures(ArchitectureSet Archs) { Architectures |= Archs; }
62  SymbolFlags getFlags() const { return Flags; }
63 
64  bool isWeakDefined() const {
66  }
67 
68  bool isWeakReferenced() const {
70  }
71 
72  bool isThreadLocalValue() const {
73  return (Flags & SymbolFlags::ThreadLocalValue) ==
75  }
76 
77  bool isUndefined() const {
79  }
80 
81 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
82  void dump(raw_ostream &OS) const;
83  void dump() const { dump(llvm::errs()); }
84 #endif
85 
86 private:
88  ArchitectureSet Architectures;
90  SymbolFlags Flags;
91 };
92 
93 } // end namespace MachO.
94 } // end namespace llvm.
95 
96 #endif // LLVM_TEXTAPI_MACHO_SYMBOL_H
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
SymbolFlags getFlags() const
Definition: Symbol.h:62
This class represents lattice values for constants.
Definition: AllocatorList.h:23
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
StringRef getName() const
Definition: Symbol.h:59
bool isWeakReferenced() const
Definition: Symbol.h:68
SymbolFlags
Symbol flags.
Definition: Symbol.h:24
constexpr Symbol(SymbolKind Kind, StringRef Name, ArchitectureSet Architectures, SymbolFlags Flags)
Definition: Symbol.h:54
void dump() const
Definition: Symbol.h:83
void addArchitectures(ArchitectureSet Archs)
Definition: Symbol.h:61
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
bool isThreadLocalValue() const
Definition: Symbol.h:72
bool isUndefined() const
Definition: Symbol.h:77
ArchitectureSet getArchitectures() const
Definition: Symbol.h:60
bool isWeakDefined() const
Definition: Symbol.h:64
SymbolKind getKind() const
Definition: Symbol.h:58
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48