LLVM  3.7.0
GlobalAlias.h
Go to the documentation of this file.
1 //===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- 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 // This file contains the declaration of the GlobalAlias class, which
11 // represents a single function or variable alias in the IR.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_IR_GLOBALALIAS_H
16 #define LLVM_IR_GLOBALALIAS_H
17 
18 #include "llvm/ADT/Twine.h"
19 #include "llvm/ADT/ilist_node.h"
20 #include "llvm/IR/GlobalValue.h"
21 #include "llvm/IR/OperandTraits.h"
22 
23 namespace llvm {
24 
25 class Module;
26 template<typename ValueSubClass, typename ItemParentClass>
27  class SymbolTableListTraits;
28 
29 class GlobalAlias : public GlobalValue, public ilist_node<GlobalAlias> {
31  void operator=(const GlobalAlias &) = delete;
32  GlobalAlias(const GlobalAlias &) = delete;
33 
34  void setParent(Module *parent);
35 
37  Constant *Aliasee, Module *Parent);
38 
39 public:
40  // allocate space for exactly one operand
41  void *operator new(size_t s) {
42  return User::operator new(s, 1);
43  }
44 
45  /// If a parent module is specified, the alias is automatically inserted into
46  /// the end of the specified module's alias list.
48  const Twine &Name, Constant *Aliasee,
49  Module *Parent);
50 
51  // Without the Aliasee.
53  const Twine &Name, Module *Parent);
54 
55  // The module is taken from the Aliasee.
57  const Twine &Name, GlobalValue *Aliasee);
58 
59  // Type, Parent and AddressSpace taken from the Aliasee.
61  GlobalValue *Aliasee);
62 
63  // Linkage, Type, Parent and AddressSpace taken from the Aliasee.
64  static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee);
65 
66  /// Provide fast operand accessors
68 
69  /// removeFromParent - This method unlinks 'this' from the containing module,
70  /// but does not delete it.
71  ///
72  void removeFromParent() override;
73 
74  /// eraseFromParent - This method unlinks 'this' from the containing module
75  /// and deletes it.
76  ///
77  void eraseFromParent() override;
78 
79  /// These methods retrive and set alias target.
80  void setAliasee(Constant *Aliasee);
81  const Constant *getAliasee() const {
82  return const_cast<GlobalAlias *>(this)->getAliasee();
83  }
85  return getOperand(0);
86  }
87 
88  const GlobalObject *getBaseObject() const {
89  return const_cast<GlobalAlias *>(this)->getBaseObject();
90  }
93  }
94 
95  const GlobalObject *getBaseObject(const DataLayout &DL, APInt &Offset) const {
96  return const_cast<GlobalAlias *>(this)->getBaseObject(DL, Offset);
97  }
99  return dyn_cast<GlobalObject>(
101  }
102 
103  static bool isValidLinkage(LinkageTypes L) {
104  return isExternalLinkage(L) || isLocalLinkage(L) ||
106  }
107 
108  // Methods for support type inquiry through isa, cast, and dyn_cast:
109  static inline bool classof(const Value *V) {
110  return V->getValueID() == Value::GlobalAliasVal;
111  }
112 };
113 
114 template <>
116  public FixedNumOperandTraits<GlobalAlias, 1> {
117 };
118 
120 
121 } // End llvm namespace
122 
123 #endif
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:104
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
static bool isExternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:196
const GlobalObject * getBaseObject(const DataLayout &DL, APInt &Offset) const
Definition: GlobalAlias.h:95
const Constant * getAliasee() const
Definition: GlobalAlias.h:81
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:226
static bool isLinkOnceLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:205
Constant * getAliasee()
Definition: GlobalAlias.h:84
static bool classof(const Value *V)
Definition: GlobalAlias.h:109
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
Value * stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, APInt &Offset)
Accumulate offsets from stripInBoundsConstantOffsets().
Definition: Value.cpp:470
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
LinkageTypes Linkage
Definition: GlobalValue.h:79
PointerType - Class to represent pointers.
Definition: DerivedTypes.h:449
static GlobalAlias * create(PointerType *Ty, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
Definition: Globals.cpp:243
This is an important base class in LLVM.
Definition: Constant.h:41
Value * stripInBoundsOffsets()
Strip off pointer casts and inbounds GEPs.
Definition: Value.cpp:507
static bool isValidLinkage(LinkageTypes L)
Definition: GlobalAlias.h:103
void removeFromParent() override
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it...
Definition: Globals.cpp:273
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:362
GlobalObject * getBaseObject(const DataLayout &DL, APInt &Offset)
Definition: GlobalAlias.h:98
Value * getOperand(unsigned i) const
Definition: User.h:118
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant)
Provide fast operand accessors.
static bool isWeakLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:214
Class for arbitrary precision integers.
Definition: APInt.h:73
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
Definition: Globals.cpp:277
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:39
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:285
ilist_node - Base class that provides next/prev services for nodes that use ilist_nextprev_traits or ...
Definition: ilist_node.h:43
Compile-time customization of User operands.
Definition: User.h:34
const GlobalObject * getBaseObject() const
Definition: GlobalAlias.h:88
LLVM Value Representation.
Definition: Value.h:69
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:31
GlobalObject * getBaseObject()
Definition: GlobalAlias.h:91
void setAliasee(Constant *Aliasee)
These methods retrive and set alias target.
Definition: Globals.cpp:281