[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment
[llvm-core.git] / include / llvm / TextAPI / MachO / Symbol.h
blob3c7ff5e0f4ea3c8cc1d38fc20382e8617bd56235
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TEXTAPI_MACHO_SYMBOL_H
10 #define LLVM_TEXTAPI_MACHO_SYMBOL_H
12 #include "llvm/ADT/BitmaskEnum.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/Error.h"
15 #include "llvm/Support/raw_ostream.h"
16 #include "llvm/TextAPI/MachO/ArchitectureSet.h"
18 namespace llvm {
19 namespace MachO {
21 // clang-format off
23 /// Symbol flags.
24 enum class SymbolFlags : uint8_t {
25 /// No flags
26 None = 0,
28 /// Thread-local value symbol
29 ThreadLocalValue = 1U << 0,
31 /// Weak defined symbol
32 WeakDefined = 1U << 1,
34 /// Weak referenced symbol
35 WeakReferenced = 1U << 2,
37 /// Undefined
38 Undefined = 1U << 3,
40 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Undefined),
43 // clang-format on
45 enum class SymbolKind : uint8_t {
46 GlobalSymbol,
47 ObjectiveCClass,
48 ObjectiveCClassEHType,
49 ObjectiveCInstanceVariable,
52 class Symbol {
53 public:
54 constexpr Symbol(SymbolKind Kind, StringRef Name,
55 ArchitectureSet Architectures, SymbolFlags Flags)
56 : Name(Name), Architectures(Architectures), Kind(Kind), Flags(Flags) {}
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; }
64 bool isWeakDefined() const {
65 return (Flags & SymbolFlags::WeakDefined) == SymbolFlags::WeakDefined;
68 bool isWeakReferenced() const {
69 return (Flags & SymbolFlags::WeakReferenced) == SymbolFlags::WeakReferenced;
72 bool isThreadLocalValue() const {
73 return (Flags & SymbolFlags::ThreadLocalValue) ==
74 SymbolFlags::ThreadLocalValue;
77 bool isUndefined() const {
78 return (Flags & SymbolFlags::Undefined) == SymbolFlags::Undefined;
81 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
82 void dump(raw_ostream &OS) const;
83 void dump() const { dump(llvm::errs()); }
84 #endif
86 private:
87 StringRef Name;
88 ArchitectureSet Architectures;
89 SymbolKind Kind;
90 SymbolFlags Flags;
93 } // end namespace MachO.
94 } // end namespace llvm.
96 #endif // LLVM_TEXTAPI_MACHO_SYMBOL_H