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
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_GLOBAL_ALIAS_H
|
|
|
|
#define LLVM_GLOBAL_ALIAS_H
|
|
|
|
|
|
|
|
#include "llvm/GlobalValue.h"
|
2008-05-10 08:32:32 +00:00
|
|
|
#include "llvm/OperandTraits.h"
|
2008-07-28 21:51:04 +00:00
|
|
|
#include "llvm/ADT/ilist_node.h"
|
2009-12-29 07:12:03 +00:00
|
|
|
#include "llvm/ADT/Twine.h"
|
2007-04-25 16:42:39 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class Module;
|
|
|
|
class Constant;
|
|
|
|
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>;
|
|
|
|
void operator=(const GlobalAlias &); // Do not implement
|
|
|
|
GlobalAlias(const GlobalAlias &); // Do not implement
|
|
|
|
|
|
|
|
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 = "",
|
2007-04-28 13:45:00 +00:00
|
|
|
Constant* Aliasee = 0, Module *Parent = 0);
|
2007-04-25 16:42:39 +00:00
|
|
|
|
2008-05-10 08:32:32 +00:00
|
|
|
/// Provide fast operand accessors
|
|
|
|
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
|
|
|
|
|
2007-04-25 16:42:39 +00:00
|
|
|
/// removeFromParent - This method unlinks 'this' from the containing module,
|
|
|
|
/// but does not delete it.
|
|
|
|
///
|
2008-08-29 07:30:15 +00:00
|
|
|
virtual void removeFromParent();
|
2007-04-25 16:42:39 +00:00
|
|
|
|
|
|
|
/// eraseFromParent - This method unlinks 'this' from the containing module
|
|
|
|
/// and deletes it.
|
|
|
|
///
|
2008-08-29 07:30:15 +00:00
|
|
|
virtual void eraseFromParent();
|
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 {
|
2007-04-28 13:45:00 +00:00
|
|
|
return cast_or_null<Constant>(getOperand(0));
|
|
|
|
}
|
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() {
|
2007-04-28 13:45:00 +00:00
|
|
|
return cast_or_null<Constant>(getOperand(0));
|
|
|
|
}
|
2007-04-29 18:02:48 +00:00
|
|
|
/// getAliasedGlobal() - Aliasee can be either global or bitcast of
|
|
|
|
/// global. This method retrives the global for both aliasee flavours.
|
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
|
|
|
const GlobalValue *getAliasedGlobal() const;
|
2008-03-11 22:28:56 +00:00
|
|
|
|
2008-03-22 07:48:08 +00:00
|
|
|
/// resolveAliasedGlobal() - This method tries to ultimately resolve the alias
|
|
|
|
/// by going through the aliasing chain and trying to find the very last
|
2008-09-09 20:05:04 +00:00
|
|
|
/// global. Returns NULL if a cycle was found. If stopOnWeak is false, then
|
2008-09-09 18:23:48 +00:00
|
|
|
/// the whole chain aliasing chain is traversed, otherwise - only strong
|
|
|
|
/// aliases.
|
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
|
|
|
const GlobalValue *resolveAliasedGlobal(bool stopOnWeak = true) const;
|
2008-03-11 22:28:56 +00:00
|
|
|
|
2007-04-25 16:42:39 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
|
|
static inline bool classof(const GlobalAlias *) { return true; }
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalAlias, Value)
|
|
|
|
|
2007-04-25 16:42:39 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|