mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-03 02:30:00 +00:00
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
101 lines
3.4 KiB
C++
101 lines
3.4 KiB
C++
//===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains the declaration of the GlobalAlias class, which
|
|
// represents a single function or variable alias in the IR.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_GLOBAL_ALIAS_H
|
|
#define LLVM_GLOBAL_ALIAS_H
|
|
|
|
#include "llvm/GlobalValue.h"
|
|
#include "llvm/OperandTraits.h"
|
|
#include "llvm/ADT/ilist_node.h"
|
|
#include "llvm/ADT/Twine.h"
|
|
|
|
namespace llvm {
|
|
|
|
class Module;
|
|
class Constant;
|
|
template<typename ValueSubClass, typename ItemParentClass>
|
|
class SymbolTableListTraits;
|
|
|
|
class GlobalAlias : public GlobalValue, public ilist_node<GlobalAlias> {
|
|
friend class SymbolTableListTraits<GlobalAlias, Module>;
|
|
void operator=(const GlobalAlias &); // Do not implement
|
|
GlobalAlias(const GlobalAlias &); // Do not implement
|
|
|
|
void setParent(Module *parent);
|
|
|
|
public:
|
|
// allocate space for exactly one operand
|
|
void *operator new(size_t s) {
|
|
return User::operator new(s, 1);
|
|
}
|
|
/// GlobalAlias ctor - If a parent module is specified, the alias is
|
|
/// automatically inserted into the end of the specified module's alias list.
|
|
GlobalAlias(const Type *Ty, LinkageTypes Linkage, const Twine &Name = "",
|
|
Constant* Aliasee = 0, Module *Parent = 0);
|
|
|
|
/// Provide fast operand accessors
|
|
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
|
|
|
|
/// isDeclaration - Is this global variable lacking an initializer? If so,
|
|
/// the global variable is defined in some other translation unit, and is thus
|
|
/// only a declaration here.
|
|
virtual bool isDeclaration() const;
|
|
|
|
/// removeFromParent - This method unlinks 'this' from the containing module,
|
|
/// but does not delete it.
|
|
///
|
|
virtual void removeFromParent();
|
|
|
|
/// eraseFromParent - This method unlinks 'this' from the containing module
|
|
/// and deletes it.
|
|
///
|
|
virtual void eraseFromParent();
|
|
|
|
/// set/getAliasee - These methods retrive and set alias target.
|
|
void setAliasee(Constant *GV);
|
|
const Constant *getAliasee() const {
|
|
return cast_or_null<Constant>(getOperand(0));
|
|
}
|
|
Constant *getAliasee() {
|
|
return cast_or_null<Constant>(getOperand(0));
|
|
}
|
|
/// getAliasedGlobal() - Aliasee can be either global or bitcast of
|
|
/// global. This method retrives the global for both aliasee flavours.
|
|
const GlobalValue *getAliasedGlobal() const;
|
|
|
|
/// resolveAliasedGlobal() - 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. If stopOnWeak is false, then
|
|
/// the whole chain aliasing chain is traversed, otherwise - only strong
|
|
/// aliases.
|
|
const GlobalValue *resolveAliasedGlobal(bool stopOnWeak = true) const;
|
|
|
|
// 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;
|
|
}
|
|
};
|
|
|
|
template <>
|
|
struct OperandTraits<GlobalAlias> :
|
|
public FixedNumOperandTraits<GlobalAlias, 1> {
|
|
};
|
|
|
|
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalAlias, Value)
|
|
|
|
} // End llvm namespace
|
|
|
|
#endif
|