LLVM  10.0.0svn
GlobalAlias.h
Go to the documentation of this file.
1 //===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- 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 // This file contains the declaration of the GlobalAlias class, which
10 // represents a single function or variable alias in the IR.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_IR_GLOBALALIAS_H
15 #define LLVM_IR_GLOBALALIAS_H
16 
17 #include "llvm/ADT/ilist_node.h"
19 #include "llvm/IR/Value.h"
20 
21 namespace llvm {
22 
23 class Twine;
24 class Module;
25 template <typename ValueSubClass> class SymbolTableListTraits;
26 
28  public ilist_node<GlobalAlias> {
30 
32  const Twine &Name, Constant *Aliasee, Module *Parent);
33 
34 public:
35  GlobalAlias(const GlobalAlias &) = delete;
36  GlobalAlias &operator=(const GlobalAlias &) = delete;
37 
38  /// If a parent module is specified, the alias is automatically inserted into
39  /// the end of the specified module's alias list.
40  static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
42  Constant *Aliasee, Module *Parent);
43 
44  // Without the Aliasee.
45  static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
47  Module *Parent);
48 
49  // The module is taken from the Aliasee.
50  static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
52  GlobalValue *Aliasee);
53 
54  // Type, Parent and AddressSpace taken from the Aliasee.
56  GlobalValue *Aliasee);
57 
58  // Linkage, Type, Parent and AddressSpace taken from the Aliasee.
59  static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee);
60 
61  /// removeFromParent - This method unlinks 'this' from the containing module,
62  /// but does not delete it.
63  ///
64  void removeFromParent();
65 
66  /// eraseFromParent - This method unlinks 'this' from the containing module
67  /// and deletes it.
68  ///
69  void eraseFromParent();
70 
71  /// These methods retrieve and set alias target.
72  void setAliasee(Constant *Aliasee);
73  const Constant *getAliasee() const {
74  return getIndirectSymbol();
75  }
77  return getIndirectSymbol();
78  }
79 
80  static bool isValidLinkage(LinkageTypes L) {
81  return isExternalLinkage(L) || isLocalLinkage(L) ||
83  }
84 
85  // Methods for support type inquiry through isa, cast, and dyn_cast:
86  static bool classof(const Value *V) {
87  return V->getValueID() == Value::GlobalAliasVal;
88  }
89 };
90 
91 } // end namespace llvm
92 
93 #endif // LLVM_IR_GLOBALALIAS_H
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:484
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:66
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static bool isExternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:300
GlobalAlias & operator=(const GlobalAlias &)=delete
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:330
static bool isLinkOnceLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:309
Constant * getAliasee()
Definition: GlobalAlias.h:76
void eraseFromParent()
eraseFromParent - This method unlinks &#39;this&#39; from the containing module and deletes it...
Definition: Globals.cpp:518
static bool classof(const Value *V)
Definition: GlobalAlias.h:86
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important base class in LLVM.
Definition: Constant.h:41
static bool isValidLinkage(LinkageTypes L)
Definition: GlobalAlias.h:80
static bool isWeakLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:318
AddressSpace
Definition: NVPTXBaseInfo.h:21
unsigned Linkage
Definition: GlobalValue.h:94
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
void removeFromParent()
removeFromParent - This method unlinks &#39;this&#39; from the containing module, but does not delete it...
Definition: Globals.cpp:514
const Constant * getIndirectSymbol() const
LLVM Value Representation.
Definition: Value.h:74
static GlobalAlias * create(Type *Ty, unsigned AddressSpace, 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:485
void setAliasee(Constant *Aliasee)
These methods retrieve and set alias target.
Definition: Globals.cpp:522
const Constant * getAliasee() const
Definition: GlobalAlias.h:73