LLVM  3.7.0
JITSymbolFlags.h
Go to the documentation of this file.
1 //===------ JITSymbolFlags.h - Flags for symbols in the JIT -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Symbol flags for symbols in the JIT (e.g. weak, exported).
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_EXECUTIONENGINE_JITSYMBOLFLAGS_H
15 #define LLVM_EXECUTIONENGINE_JITSYMBOLFLAGS_H
16 
17 #include "llvm/IR/GlobalValue.h"
18 
19 namespace llvm {
20 
21 /// @brief Flags for symbols in the JIT.
22 enum class JITSymbolFlags : char {
23  None = 0,
24  Weak = 1U << 0,
25  Exported = 1U << 1
26 };
27 
29  typedef std::underlying_type<JITSymbolFlags>::type UT;
30  return static_cast<JITSymbolFlags>(
31  static_cast<UT>(LHS) | static_cast<UT>(RHS));
32 }
33 
35  LHS = LHS | RHS;
36  return LHS;
37 }
38 
40  typedef std::underlying_type<JITSymbolFlags>::type UT;
41  return static_cast<JITSymbolFlags>(
42  static_cast<UT>(LHS) & static_cast<UT>(RHS));
43 }
44 
46  LHS = LHS & RHS;
47  return LHS;
48 }
49 
50 /// @brief Base class for symbols in the JIT.
52 public:
53  JITSymbolBase(JITSymbolFlags Flags) : Flags(Flags) {}
54 
55  JITSymbolFlags getFlags() const { return Flags; }
56 
57  bool isWeak() const {
58  return (Flags & JITSymbolFlags::Weak) == JITSymbolFlags::Weak;
59  }
60 
61  bool isExported() const {
63  }
64 
67  if (GV.hasWeakLinkage())
68  Flags |= JITSymbolFlags::Weak;
69  if (!GV.hasLocalLinkage() && !GV.hasHiddenVisibility())
70  Flags |= JITSymbolFlags::Exported;
71  return Flags;
72 
73  }
74 
75 private:
76  JITSymbolFlags Flags;
77 };
78 
79 } // end namespace llvm
80 
81 #endif
SmallBitVector operator&(const SmallBitVector &LHS, const SmallBitVector &RHS)
bool isExported() const
Base class for symbols in the JIT.
SmallBitVector operator|(const SmallBitVector &LHS, const SmallBitVector &RHS)
JITSymbolBase(JITSymbolFlags Flags)
bool isWeak() const
bool operator|=(SparseBitVector< ElementSize > &LHS, const SparseBitVector< ElementSize > *RHS)
JITSymbolFlags
Flags for symbols in the JIT.
bool hasHiddenVisibility() const
Definition: GlobalValue.h:141
bool hasWeakLinkage() const
Definition: GlobalValue.h:268
static JITSymbolFlags flagsFromGlobalValue(const GlobalValue &GV)
JITSymbolFlags getFlags() const
bool hasLocalLinkage() const
Definition: GlobalValue.h:280
bool operator&=(SparseBitVector< ElementSize > *LHS, const SparseBitVector< ElementSize > &RHS)