LLVM  14.0.0git
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"
18 #include "llvm/IR/GlobalValue.h"
19 #include "llvm/IR/OperandTraits.h"
20 #include "llvm/IR/Value.h"
21 
22 namespace llvm {
23 
24 class Twine;
25 class Module;
26 template <typename ValueSubClass> class SymbolTableListTraits;
27 
28 class GlobalAlias : public GlobalValue, 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  // allocate space for exactly one operand
62  void *operator new(size_t S) { return User::operator new(S, 1); }
63  void operator delete(void *Ptr) { User::operator delete(Ptr); }
64 
65  /// Provide fast operand accessors
67 
68  void copyAttributesFrom(const GlobalAlias *Src) {
70  }
71 
72  /// removeFromParent - This method unlinks 'this' from the containing module,
73  /// but does not delete it.
74  ///
75  void removeFromParent();
76 
77  /// eraseFromParent - This method unlinks 'this' from the containing module
78  /// and deletes it.
79  ///
80  void eraseFromParent();
81 
82  /// These methods retrieve and set alias target.
83  void setAliasee(Constant *Aliasee);
84  const Constant *getAliasee() const {
85  return static_cast<Constant *>(Op<0>().get());
86  }
87  Constant *getAliasee() { return static_cast<Constant *>(Op<0>().get()); }
88 
89  const GlobalObject *getAliaseeObject() const;
91  return const_cast<GlobalObject *>(
92  static_cast<const GlobalAlias *>(this)->getAliaseeObject());
93  }
94 
95  static bool isValidLinkage(LinkageTypes L) {
96  return isExternalLinkage(L) || isLocalLinkage(L) ||
98  }
99 
100  // Methods for support type inquiry through isa, cast, and dyn_cast:
101  static bool classof(const Value *V) {
102  return V->getValueID() == Value::GlobalAliasVal;
103  }
104 };
105 
106 template <>
108  : public FixedNumOperandTraits<GlobalAlias, 1> {};
109 
111 
112 } // end namespace llvm
113 
114 #endif // LLVM_IR_GLOBALALIAS_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::GlobalValue::isLocalLinkage
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:332
llvm::GlobalAlias::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant)
Provide fast operand accessors.
llvm::GlobalAlias::getAliaseeObject
GlobalObject * getAliaseeObject()
Definition: GlobalAlias.h:90
llvm::GlobalAlias
Definition: GlobalAlias.h:28
llvm::GlobalAlias::copyAttributesFrom
void copyAttributesFrom(const GlobalAlias *Src)
Definition: GlobalAlias.h:68
llvm::GlobalAlias::classof
static bool classof(const Value *V)
Definition: GlobalAlias.h:101
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
DEFINE_TRANSPARENT_OPERAND_ACCESSORS
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Definition: OperandTraits.h:125
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
llvm::GlobalAlias::operator=
GlobalAlias & operator=(const GlobalAlias &)=delete
GlobalValue.h
llvm::OperandTraits
Compile-time customization of User operands.
Definition: User.h:42
llvm::GlobalObject
Definition: GlobalObject.h:28
llvm::GlobalValue::copyAttributesFrom
void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
Definition: Globals.cpp:65
llvm::Value::getValueID
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:532
OperandTraits.h
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::GlobalAlias::getAliasee
Constant * getAliasee()
Definition: GlobalAlias.h:87
llvm::SymbolTableListTraits
Definition: GlobalAlias.h:26
llvm::GlobalValue::Linkage
unsigned Linkage
Definition: GlobalValue.h:94
llvm::GlobalAlias::isValidLinkage
static bool isValidLinkage(LinkageTypes L)
Definition: GlobalAlias.h:95
llvm::GlobalValue::isExternalLinkage
static bool isExternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:299
llvm::GlobalValue::isWeakLinkage
static bool isWeakLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:320
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::GlobalAlias::getAliasee
const Constant * getAliasee() const
Definition: GlobalAlias.h:84
llvm::ilist_node
Definition: ilist_node.h:148
llvm::GlobalValue::isLinkOnceLinkage
static bool isLinkOnceLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:311
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::GlobalAlias::create
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:467
llvm::GlobalAlias::getAliaseeObject
const GlobalObject * getAliaseeObject() const
Definition: Globals.cpp:509
llvm::FixedNumOperandTraits
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:30
ilist_node.h
llvm::GlobalAlias::eraseFromParent
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:499
Value.h
llvm::GlobalValue::Parent
Module * Parent
Definition: GlobalValue.h:166
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::GlobalAlias::removeFromParent
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
Definition: Globals.cpp:495
llvm::GlobalAlias::setAliasee
void setAliasee(Constant *Aliasee)
These methods retrieve and set alias target.
Definition: Globals.cpp:503