1f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- C++ -*-===//
2f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//
3f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//                     The LLVM Compiler Infrastructure
4f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//
5f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// This file is distributed under the University of Illinois Open Source
6f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// License. See LICENSE.TXT for details.
7f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//
8f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//===----------------------------------------------------------------------===//
9f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//
10f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// This file contains the declaration of the GlobalAlias class, which
11f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// represents a single function or variable alias in the IR.
12f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//
13f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//===----------------------------------------------------------------------===//
14f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
15f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#ifndef LLVM_IR_GLOBALALIAS_H
16f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#define LLVM_IR_GLOBALALIAS_H
17f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
18f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#include "llvm/ADT/ilist_node.h"
19f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#include "llvm/IR/GlobalIndirectSymbol.h"
20f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#include "llvm/IR/Value.h"
21f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
22f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotnamespace llvm {
23f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
24f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass Twine;
25f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass Module;
26f3014761c955345d6e05491608e73228d014afbandroid-build-team Robottemplate <typename ValueSubClass> class SymbolTableListTraits;
27f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
28f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass GlobalAlias : public GlobalIndirectSymbol,
29f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot                    public ilist_node<GlobalAlias> {
30f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  friend class SymbolTableListTraits<GlobalAlias>;
31f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
32f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
33f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot              const Twine &Name, Constant *Aliasee, Module *Parent);
34f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
35f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotpublic:
36f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  GlobalAlias(const GlobalAlias &) = delete;
37f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  GlobalAlias &operator=(const GlobalAlias &) = delete;
38f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
39f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  /// If a parent module is specified, the alias is automatically inserted into
40f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  /// the end of the specified module's alias list.
41f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
42f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot                             LinkageTypes Linkage, const Twine &Name,
43f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot                             Constant *Aliasee, Module *Parent);
44f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
45f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  // Without the Aliasee.
46f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
47f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot                             LinkageTypes Linkage, const Twine &Name,
48f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot                             Module *Parent);
49f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
50f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  // The module is taken from the Aliasee.
51f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
52f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot                             LinkageTypes Linkage, const Twine &Name,
53f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot                             GlobalValue *Aliasee);
54f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
55f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  // Type, Parent and AddressSpace taken from the Aliasee.
56f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  static GlobalAlias *create(LinkageTypes Linkage, const Twine &Name,
57f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot                             GlobalValue *Aliasee);
58f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
59f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  // Linkage, Type, Parent and AddressSpace taken from the Aliasee.
60f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee);
61f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
62f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  void copyAttributesFrom(const GlobalValue *Src) {
63f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot    GlobalValue::copyAttributesFrom(Src);
64f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  }
65f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
66f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  /// removeFromParent - This method unlinks 'this' from the containing module,
67f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  /// but does not delete it.
68f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  ///
69f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  void removeFromParent();
70f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
71f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  /// eraseFromParent - This method unlinks 'this' from the containing module
72f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  /// and deletes it.
73f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  ///
74f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  void eraseFromParent();
75f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
76f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  /// These methods retrieve and set alias target.
77f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  void setAliasee(Constant *Aliasee);
78f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  const Constant *getAliasee() const {
79f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot    return getIndirectSymbol();
80f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  }
81f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  Constant *getAliasee() {
82f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot    return getIndirectSymbol();
83f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  }
84f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
85f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  static bool isValidLinkage(LinkageTypes L) {
86f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot    return isExternalLinkage(L) || isLocalLinkage(L) ||
87f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot      isWeakLinkage(L) || isLinkOnceLinkage(L);
88f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  }
89f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
90f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  // Methods for support type inquiry through isa, cast, and dyn_cast:
91f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  static inline bool classof(const Value *V) {
92f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot    return V->getValueID() == Value::GlobalAliasVal;
93f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot  }
94f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot};
95f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
96f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot} // end namespace llvm
97f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot
98f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#endif // LLVM_IR_GLOBALALIAS_H
99