2007-04-28 13:45:00 +00:00
|
|
|
//===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- C++ -*-===//
|
2007-04-25 16:42:39 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-04-25 16:42:39 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the declaration of the GlobalAlias class, which
|
2007-04-28 13:45:00 +00:00
|
|
|
// represents a single function or variable alias in the IR.
|
2007-04-25 16:42:39 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-10 00:45:19 +00:00
|
|
|
#ifndef LLVM_IR_GLOBALALIAS_H
|
|
|
|
#define LLVM_IR_GLOBALALIAS_H
|
2007-04-25 16:42:39 +00:00
|
|
|
|
2012-12-03 17:02:12 +00:00
|
|
|
#include "llvm/ADT/Twine.h"
|
|
|
|
#include "llvm/ADT/ilist_node.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/GlobalValue.h"
|
|
|
|
#include "llvm/IR/OperandTraits.h"
|
2007-04-25 16:42:39 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class Module;
|
|
|
|
template<typename ValueSubClass, typename ItemParentClass>
|
|
|
|
class SymbolTableListTraits;
|
|
|
|
|
2008-07-28 21:51:04 +00:00
|
|
|
class GlobalAlias : public GlobalValue, public ilist_node<GlobalAlias> {
|
2007-04-25 16:42:39 +00:00
|
|
|
friend class SymbolTableListTraits<GlobalAlias, Module>;
|
2012-09-17 07:16:40 +00:00
|
|
|
void operator=(const GlobalAlias &) LLVM_DELETED_FUNCTION;
|
|
|
|
GlobalAlias(const GlobalAlias &) LLVM_DELETED_FUNCTION;
|
2007-04-25 16:42:39 +00:00
|
|
|
|
|
|
|
void setParent(Module *parent);
|
|
|
|
|
|
|
|
public:
|
2008-05-10 08:32:32 +00:00
|
|
|
// allocate space for exactly one operand
|
2008-04-06 20:25:17 +00:00
|
|
|
void *operator new(size_t s) {
|
2008-05-10 08:32:32 +00:00
|
|
|
return User::operator new(s, 1);
|
2008-04-06 20:25:17 +00:00
|
|
|
}
|
2007-04-25 16:42:39 +00:00
|
|
|
/// GlobalAlias ctor - If a parent module is specified, the alias is
|
2007-04-28 13:45:00 +00:00
|
|
|
/// automatically inserted into the end of the specified module's alias list.
|
2011-07-18 04:54:35 +00:00
|
|
|
GlobalAlias(Type *Ty, LinkageTypes Linkage, const Twine &Name = "",
|
2014-04-09 06:08:46 +00:00
|
|
|
Constant* Aliasee = nullptr, Module *Parent = nullptr);
|
2007-04-25 16:42:39 +00:00
|
|
|
|
2008-05-10 08:32:32 +00:00
|
|
|
/// Provide fast operand accessors
|
2011-08-01 12:20:36 +00:00
|
|
|
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
|
2008-05-10 08:32:32 +00:00
|
|
|
|
2007-04-25 16:42:39 +00:00
|
|
|
/// removeFromParent - This method unlinks 'this' from the containing module,
|
|
|
|
/// but does not delete it.
|
|
|
|
///
|
2014-03-05 06:35:38 +00:00
|
|
|
void removeFromParent() override;
|
2007-04-25 16:42:39 +00:00
|
|
|
|
|
|
|
/// eraseFromParent - This method unlinks 'this' from the containing module
|
|
|
|
/// and deletes it.
|
|
|
|
///
|
2014-03-05 06:35:38 +00:00
|
|
|
void eraseFromParent() override;
|
2007-04-25 16:42:39 +00:00
|
|
|
|
2007-04-28 13:45:00 +00:00
|
|
|
/// set/getAliasee - These methods retrive and set alias target.
|
Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM. One way to look at it
is through diffstat:
109 files changed, 3005 insertions(+), 5906 deletions(-)
Removing almost 3K lines of code is a good thing. Other advantages
include:
1. Value::getType() is a simple load that can be CSE'd, not a mutating
union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
uniques them. This means that the compiler doesn't merge them structurally
which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead
"const Type *" everywhere.
Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.
"LLVM 3.0" is the right time to do this.
There are still some cleanups pending after this, this patch is large enough
as-is.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134829 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 17:41:24 +00:00
|
|
|
void setAliasee(Constant *GV);
|
|
|
|
const Constant *getAliasee() const {
|
2011-08-01 12:20:36 +00:00
|
|
|
return getOperand(0);
|
2007-04-28 13:45:00 +00:00
|
|
|
}
|
Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM. One way to look at it
is through diffstat:
109 files changed, 3005 insertions(+), 5906 deletions(-)
Removing almost 3K lines of code is a good thing. Other advantages
include:
1. Value::getType() is a simple load that can be CSE'd, not a mutating
union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
uniques them. This means that the compiler doesn't merge them structurally
which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead
"const Type *" everywhere.
Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.
"LLVM 3.0" is the right time to do this.
There are still some cleanups pending after this, this patch is large enough
as-is.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134829 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 17:41:24 +00:00
|
|
|
Constant *getAliasee() {
|
2011-08-01 12:20:36 +00:00
|
|
|
return getOperand(0);
|
2007-04-28 13:45:00 +00:00
|
|
|
}
|
2014-03-27 15:26:56 +00:00
|
|
|
|
|
|
|
/// This method tries to ultimately resolve the alias by going through the
|
|
|
|
/// aliasing chain and trying to find the very last global. Returns NULL if a
|
|
|
|
/// cycle was found.
|
2013-08-19 23:13:33 +00:00
|
|
|
GlobalValue *getAliasedGlobal();
|
|
|
|
const GlobalValue *getAliasedGlobal() const {
|
|
|
|
return const_cast<GlobalAlias *>(this)->getAliasedGlobal();
|
|
|
|
}
|
2008-03-11 22:28:56 +00:00
|
|
|
|
2013-10-09 16:07:32 +00:00
|
|
|
static bool isValidLinkage(LinkageTypes L) {
|
|
|
|
return isExternalLinkage(L) || isLocalLinkage(L) ||
|
|
|
|
isWeakLinkage(L) || isLinkOnceLinkage(L);
|
|
|
|
}
|
|
|
|
|
2007-04-25 16:42:39 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
|
|
static inline bool classof(const Value *V) {
|
|
|
|
return V->getValueID() == Value::GlobalAliasVal;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-05-10 08:32:32 +00:00
|
|
|
template <>
|
2011-01-11 15:07:38 +00:00
|
|
|
struct OperandTraits<GlobalAlias> :
|
|
|
|
public FixedNumOperandTraits<GlobalAlias, 1> {
|
2008-05-10 08:32:32 +00:00
|
|
|
};
|
|
|
|
|
2011-08-22 09:37:03 +00:00
|
|
|
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalAlias, Constant)
|
2008-05-10 08:32:32 +00:00
|
|
|
|
2007-04-25 16:42:39 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|