2007-04-28 15:45:00 +02:00
|
|
|
//===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- C++ -*-===//
|
2007-04-25 18:42:39 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-04-25 18:42:39 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the declaration of the GlobalAlias class, which
|
2007-04-28 15:45:00 +02:00
|
|
|
// represents a single function or variable alias in the IR.
|
2007-04-25 18:42:39 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_GLOBAL_ALIAS_H
|
|
|
|
#define LLVM_GLOBAL_ALIAS_H
|
|
|
|
|
|
|
|
#include "llvm/GlobalValue.h"
|
2008-05-10 10:32:32 +02:00
|
|
|
#include "llvm/OperandTraits.h"
|
2008-07-28 23:51:04 +02:00
|
|
|
#include "llvm/ADT/ilist_node.h"
|
2009-12-29 08:12:03 +01:00
|
|
|
#include "llvm/ADT/Twine.h"
|
2007-04-25 18:42:39 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class Module;
|
|
|
|
class Constant;
|
|
|
|
template<typename ValueSubClass, typename ItemParentClass>
|
|
|
|
class SymbolTableListTraits;
|
|
|
|
|
2008-07-28 23:51:04 +02:00
|
|
|
class GlobalAlias : public GlobalValue, public ilist_node<GlobalAlias> {
|
2007-04-25 18:42:39 +02: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 10:32:32 +02:00
|
|
|
// allocate space for exactly one operand
|
2008-04-06 22:25:17 +02:00
|
|
|
void *operator new(size_t s) {
|
2008-05-10 10:32:32 +02:00
|
|
|
return User::operator new(s, 1);
|
2008-04-06 22:25:17 +02:00
|
|
|
}
|
2007-04-25 18:42:39 +02:00
|
|
|
/// GlobalAlias ctor - If a parent module is specified, the alias is
|
2007-04-28 15:45:00 +02:00
|
|
|
/// automatically inserted into the end of the specified module's alias list.
|
2011-07-18 06:54:35 +02:00
|
|
|
GlobalAlias(Type *Ty, LinkageTypes Linkage, const Twine &Name = "",
|
2007-04-28 15:45:00 +02:00
|
|
|
Constant* Aliasee = 0, Module *Parent = 0);
|
2007-04-25 18:42:39 +02:00
|
|
|
|
2008-05-10 10:32:32 +02:00
|
|
|
/// Provide fast operand accessors
|
|
|
|
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
|
|
|
|
|
2007-04-25 18:42:39 +02:00
|
|
|
/// removeFromParent - This method unlinks 'this' from the containing module,
|
|
|
|
/// but does not delete it.
|
|
|
|
///
|
2008-08-29 09:30:15 +02:00
|
|
|
virtual void removeFromParent();
|
2007-04-25 18:42:39 +02:00
|
|
|
|
|
|
|
/// eraseFromParent - This method unlinks 'this' from the containing module
|
|
|
|
/// and deletes it.
|
|
|
|
///
|
2008-08-29 09:30:15 +02:00
|
|
|
virtual void eraseFromParent();
|
2007-04-25 18:42:39 +02:00
|
|
|
|
2007-04-28 15:45:00 +02: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.
llvm-svn: 134829
2011-07-09 19:41:24 +02:00
|
|
|
void setAliasee(Constant *GV);
|
|
|
|
const Constant *getAliasee() const {
|
2007-04-28 15:45:00 +02: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.
llvm-svn: 134829
2011-07-09 19:41:24 +02:00
|
|
|
Constant *getAliasee() {
|
2007-04-28 15:45:00 +02:00
|
|
|
return cast_or_null<Constant>(getOperand(0));
|
|
|
|
}
|
2007-04-29 20:02:48 +02: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.
llvm-svn: 134829
2011-07-09 19:41:24 +02:00
|
|
|
const GlobalValue *getAliasedGlobal() const;
|
2008-03-11 23:28:56 +01:00
|
|
|
|
2008-03-22 08:48:08 +01: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 22:05:04 +02:00
|
|
|
/// global. Returns NULL if a cycle was found. If stopOnWeak is false, then
|
2008-09-09 20:23:48 +02: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.
llvm-svn: 134829
2011-07-09 19:41:24 +02:00
|
|
|
const GlobalValue *resolveAliasedGlobal(bool stopOnWeak = true) const;
|
2008-03-11 23:28:56 +01:00
|
|
|
|
2007-04-25 18:42:39 +02: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 10:32:32 +02:00
|
|
|
template <>
|
2011-01-11 16:07:38 +01:00
|
|
|
struct OperandTraits<GlobalAlias> :
|
|
|
|
public FixedNumOperandTraits<GlobalAlias, 1> {
|
2008-05-10 10:32:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalAlias, Value)
|
|
|
|
|
2007-04-25 18:42:39 +02:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|